[nginx] Fixed ETag memory allocation error handling.

Maxim Dounin mdounin at mdounin.ru
Mon Sep 8 20:27:58 UTC 2014


details:   http://hg.nginx.org/nginx/rev/51fe42cc7876
branches:  
changeset: 5825:51fe42cc7876
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Mon Sep 08 21:36:03 2014 +0400
description:
Fixed ETag memory allocation error handling.

The etag->hash must be set to 0 to avoid an empty ETag header being
returned with the 500 Internal Server Error page after the memory
allocation failure.

Reported by Markus Linnala.

diffstat:

 src/http/ngx_http_core_module.c |  1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diffs (11 lines):

diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -1837,6 +1837,7 @@ ngx_http_set_etag(ngx_http_request_t *r)
 
     etag->value.data = ngx_pnalloc(r->pool, NGX_OFF_T_LEN + NGX_TIME_T_LEN + 3);
     if (etag->value.data == NULL) {
+        etag->hash = 0;
         return NGX_ERROR;
     }
 



More information about the nginx-devel mailing list