diff options
author | Igor Sysoev <igor@sysoev.ru> | 2009-09-25 09:30:06 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2009-09-25 09:30:06 +0000 |
commit | a552ab476e95cd034d2463b3de95239010a8e0b0 (patch) | |
tree | 6bac5d4431e5bf59c800d9db195a76eb026869b1 /src/http/modules/ngx_http_dav_module.c | |
parent | 7f6d71bbc848360f4f6b1ec276736b88fb15b3f0 (diff) | |
download | nginx-a552ab476e95cd034d2463b3de95239010a8e0b0.tar.gz nginx-a552ab476e95cd034d2463b3de95239010a8e0b0.zip |
check unsafe Destination
Diffstat (limited to 'src/http/modules/ngx_http_dav_module.c')
-rw-r--r-- | src/http/modules/ngx_http_dav_module.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/http/modules/ngx_http_dav_module.c b/src/http/modules/ngx_http_dav_module.c index 38e928c3d..1502fbf25 100644 --- a/src/http/modules/ngx_http_dav_module.c +++ b/src/http/modules/ngx_http_dav_module.c @@ -516,8 +516,8 @@ ngx_http_dav_copy_move_handler(ngx_http_request_t *r) size_t len, root; ngx_err_t err; ngx_int_t rc, depth; - ngx_uint_t overwrite, slash, dir; - ngx_str_t path, uri; + ngx_uint_t overwrite, slash, dir, flags; + ngx_str_t path, uri, duri, args; ngx_tree_ctx_t tree; ngx_copy_file_t cf; ngx_file_info_t fi; @@ -594,6 +594,14 @@ invalid_destination: destination_done: + duri.len = last - p; + duri.data = p; + flags = 0; + + if (ngx_http_parse_unsafe_uri(r, &duri, &args, &flags) != NGX_OK) { + goto invalid_destination; + } + if ((r->uri.data[r->uri.len - 1] == '/' && *(last - 1) != '/') || (r->uri.data[r->uri.len - 1] != '/' && *(last - 1) == '/')) { @@ -656,9 +664,7 @@ overwrite_done: "http copy from: \"%s\"", path.data); uri = r->uri; - - r->uri.len = last - p; - r->uri.data = p; + r->uri = duri; ngx_http_map_uri_to_path(r, ©.path, &root, 0); |