From af5a3ce4740e78b667994ed444a72bec610b3ec8 Mon Sep 17 00:00:00 2001 From: aszlig Date: Thu, 18 Apr 2019 08:13:41 +0200 Subject: [PATCH] nginx: Fix memleak in nix-etag patch The original patch introduced a new "real" variable which gets populated (and allocated) via ngx_realpath(). It's properly freed in error conditions but it won't be freed if ngx_http_set_etag returns successfully. Adding another ngx_free() just before returning fixes that memory leak. I also fixed a small indentation issue along the way. Signed-off-by: aszlig --- pkgs/servers/http/nginx/nix-etag-1.15.4.patch | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/servers/http/nginx/nix-etag-1.15.4.patch b/pkgs/servers/http/nginx/nix-etag-1.15.4.patch index 4d8a6510cbf..1a8dcb4303a 100644 --- a/pkgs/servers/http/nginx/nix-etag-1.15.4.patch +++ b/pkgs/servers/http/nginx/nix-etag-1.15.4.patch @@ -19,7 +19,7 @@ index c57ec00c..b7992de2 100644 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); -@@ -1598,16 +1599,59 @@ ngx_http_set_etag(ngx_http_request_t *r) +@@ -1598,16 +1599,61 @@ ngx_http_set_etag(ngx_http_request_t *r) etag->hash = 1; ngx_str_set(&etag->key, "ETag"); @@ -44,7 +44,7 @@ index c57ec00c..b7992de2 100644 + && real[NIX_STORE_LEN] == '/' + && real[NIX_STORE_LEN + 1] != '\0') + { -+ ptr1 = real + NIX_STORE_LEN; ++ ptr1 = real + NIX_STORE_LEN; + *ptr1 = '"'; + + ptr2 = (u_char *) ngx_strchr(ptr1, '-'); @@ -82,6 +82,8 @@ index c57ec00c..b7992de2 100644 + r->headers_out.content_length_n) + - etag->value.data; + } ++ ++ ngx_free(real); r->headers_out.etag = etag;