[PATCH] Rewrite: fix "return" directive without response text

Piotr Sikora piotr at aviatrix.com
Wed Feb 28 01:21:57 UTC 2024


# HG changeset patch
# User Piotr Sikora <piotr at aviatrix.com>
# Date 1708977628 0
#      Mon Feb 26 20:00:28 2024 +0000
# Branch patch008
# Node ID 3cde11b747c08c69889edc014a700317fe4d1d88
# Parent  5584232259d28489efba149f2f5ae730691ff0d4
Rewrite: fix "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>

diff -r 5584232259d2 -r 3cde11b747c0 src/http/modules/ngx_http_rewrite_module.c
--- a/src/http/modules/ngx_http_rewrite_module.c	Mon Feb 26 20:00:26 2024 +0000
+++ b/src/http/modules/ngx_http_rewrite_module.c	Mon Feb 26 20:00:28 2024 +0000
@@ -489,6 +489,7 @@
         }
 
         if (cf->args->nelts == 2) {
+            ngx_str_set(&ret->text.value, "");
             return NGX_CONF_OK;
         }
 


More information about the nginx-devel mailing list