details:   https://hg.nginx.org/nginx/rev/7aa20af4ac00
branches:  
changeset: 7604:7aa20af4ac00
user:      Ruslan Ermilov <r...@nginx.com>
date:      Mon Dec 16 15:19:01 2019 +0300
description:
Rewrite: fixed segfault with rewritten URI and "alias".

The "alias" directive cannot be used in the same location where URI
was rewritten.  This has been detected in the "rewrite ... break"
case, but not when the standalone "break" directive was used.

This change also fixes proxy_pass with URI component in a similar
case:

       location /aaa/ {
           rewrite ^ /xxx/yyy;
           break;
           proxy_pass http://localhost:8080/bbb/;
       }

Previously, the "/bbb/yyy" would be sent to a backend instead of
"/xxx/yyy".  And if location's prefix was longer than the rewritten
URI, a segmentation fault might occur.

diffstat:

 src/http/ngx_http_script.c |  9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diffs (19 lines):

diff -r e55e28e6998f -r 7aa20af4ac00 src/http/ngx_http_script.c
--- a/src/http/ngx_http_script.c        Mon Dec 16 15:19:01 2019 +0300
+++ b/src/http/ngx_http_script.c        Mon Dec 16 15:19:01 2019 +0300
@@ -1470,7 +1470,14 @@
 void
 ngx_http_script_break_code(ngx_http_script_engine_t *e)
 {
-    e->request->uri_changed = 0;
+    ngx_http_request_t  *r;
+
+    r = e->request;
+
+    if (r->uri_changed) {
+        r->valid_location = 0;
+        r->uri_changed = 0;
+    }
 
     e->ip = ngx_http_script_exit;
 }
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel

Reply via email to