[PATCH] Core: fixed inconsistent state of subrequest's headers_in list

Jan Prachař jan.prachar at gmail.com
Thu Nov 26 20:11:39 UTC 2020


# HG changeset patch
# User Jan Prachař  <jan.prachar at gmail.com>
# Date 1606420825 -3600
#      Thu Nov 26 21:00:25 2020 +0100
# Node ID cf3d537ec6706f8713a757df256f2cfccb8f9b01
# Parent  e35b529b03781e64912e0d8a72bd0f957dc08cd2
Core: fixed inconsistent state of subrequest's headers_in list

When copying structure ngx_list_t, a reference to the last part need to be
updated, if list contains only one part.

This fixes an issue, when adding a header to the subrequest's headers_in list
has no effect.

diff -r e35b529b0378 -r cf3d537ec670 src/core/ngx_list.h
--- a/src/core/ngx_list.h	Mon Sep 21 19:49:49 2020 +0200
+++ b/src/core/ngx_list.h	Thu Nov 26 21:00:25 2020 +0100
@@ -51,6 +51,15 @@
     return NGX_OK;
 }
 
+static ngx_inline void
+ngx_list_copy(ngx_list_t *target, ngx_list_t *src)
+{
+    *target = *src;
+    if (target->part.next == NULL) {
+        target->last = &target->part;
+    }
+}
+
 
 /*
  *
diff -r e35b529b0378 -r cf3d537ec670 src/http/ngx_http_core_module.c
--- a/src/http/ngx_http_core_module.c	Mon Sep 21 19:49:49 2020 +0200
+++ b/src/http/ngx_http_core_module.c	Thu Nov 26 21:00:25 2020 +0100
@@ -2364,6 +2364,7 @@
     sr->pool = r->pool;
 
     sr->headers_in = r->headers_in;
+    ngx_list_copy(&sr->headers_in.headers, &r->headers_in.headers);
 
     ngx_http_clear_content_length(sr);
     ngx_http_clear_accept_ranges(sr);



More information about the nginx-devel mailing list