[nginx] Rewrite: fixed "return" directive without response text.

Sergey Kandaurov pluknet at nginx.com
Wed Mar 27 17:46:32 UTC 2024


details:   https://hg.nginx.org/nginx/rev/dd4a570ff4ac
branches:  
changeset: 9228:dd4a570ff4ac
user:      Piotr Sikora <piotr at aviatrix.com>
date:      Mon Feb 26 20:00:28 2024 +0000
description:
Rewrite: fixed "return" directive without response text.

Previously, the response text wasn't initialized and the rewrite module
was sending response body set to NULL.

Found with UndefinedBehaviorSanitizer (pointer-overflow).

Signed-off-by: Piotr Sikora <piotr at aviatrix.com>

diffstat:

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

diffs (11 lines):

diff -r f208413f307f -r dd4a570ff4ac src/http/modules/ngx_http_rewrite_module.c
--- a/src/http/modules/ngx_http_rewrite_module.c	Mon Mar 18 17:14:30 2024 +0400
+++ b/src/http/modules/ngx_http_rewrite_module.c	Mon Feb 26 20:00:28 2024 +0000
@@ -489,6 +489,7 @@ ngx_http_rewrite_return(ngx_conf_t *cf, 
         }
 
         if (cf->args->nelts == 2) {
+            ngx_str_set(&ret->text.value, "");
             return NGX_CONF_OK;
         }
 


More information about the nginx-devel mailing list