From 17e194a128e3b6c06b4e42891282d7f7814672c7 Mon Sep 17 00:00:00 2001 From: lijunlong Date: Sat, 6 Jun 2020 06:51:24 +0800 Subject: [PATCH] fix code style and len error --- patches/nginx-1.17.8-set_uri_security_issue.patch | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/patches/nginx-1.17.8-set_uri_security_issue.patch b/patches/nginx-1.17.8-set_uri_security_issue.patch index 7daa265..04d9ef1 100644 --- a/patches/nginx-1.17.8-set_uri_security_issue.patch +++ b/patches/nginx-1.17.8-set_uri_security_issue.patch @@ -1,5 +1,5 @@ diff --git a/src/http/modules/ngx_http_static_module.c b/src/http/modules/ngx_http_static_module.c -index 282d6ee9..e889540d 100644 +index 282d6ee..899e11e 100644 --- a/src/http/modules/ngx_http_static_module.c +++ b/src/http/modules/ngx_http_static_module.c @@ -58,6 +58,8 @@ ngx_http_static_handler(ngx_http_request_t *r) @@ -11,20 +11,21 @@ index 282d6ee9..e889540d 100644 if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD|NGX_HTTP_POST))) { return NGX_HTTP_NOT_ALLOWED; -@@ -162,9 +164,20 @@ ngx_http_static_handler(ngx_http_request_t *r) +@@ -162,9 +164,21 @@ ngx_http_static_handler(ngx_http_request_t *r) *last = '/'; + escape = 2 * ngx_escape_uri(NULL, location, len, NGX_ESCAPE_URI); + if (escape > 0) { -+ uri = ngx_pnalloc(r->pool, len + 2 * escape); ++ uri = ngx_pnalloc(r->pool, len + escape); + if (uri == NULL) { + return NGX_ERROR; + } + ngx_escape_uri(uri, location, len, NGX_ESCAPE_URI); + location = uri; -+ len += 2 * escape; ++ len += escape; + } ++ } else { + escape = 2 * ngx_escape_uri(NULL, r->uri.data, r->uri.len, NGX_ESCAPE_URI); if (r->args.len) { @@ -33,13 +34,14 @@ index 282d6ee9..e889540d 100644 } location = ngx_pnalloc(r->pool, len); -@@ -173,7 +186,11 @@ ngx_http_static_handler(ngx_http_request_t *r) +@@ -173,7 +187,12 @@ ngx_http_static_handler(ngx_http_request_t *r) return NGX_HTTP_INTERNAL_SERVER_ERROR; } - last = ngx_copy(location, r->uri.data, r->uri.len); + if (escape > 0) { -+ last = (u_char *)ngx_escape_uri(location, r->uri.data, r->uri.len, NGX_ESCAPE_URI); ++ last = (u_char *) ngx_escape_uri(location, r->uri.data, r->uri.len, NGX_ESCAPE_URI); ++ + } else { + last = ngx_copy(location, r->uri.data, r->uri.len); + }