Mercurial > hg > nginx
diff src/http/modules/ngx_http_dav_module.c @ 3161:d430c6ab1c99
check unsafe Destination
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 25 Sep 2009 09:30:06 +0000 |
parents | 524ba56ba9f7 |
children | 6ddaac3e0bf7 |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_dav_module.c Fri Sep 25 09:13:08 2009 +0000 +++ b/src/http/modules/ngx_http_dav_module.c Fri Sep 25 09:30:06 2009 +0000 @@ -516,8 +516,8 @@ 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 @@ 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 @@ "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);