[nginx] svn commit: r4618 - trunk/src/http

mdounin at mdounin.ru mdounin at mdounin.ru
Fri May 11 13:19:22 UTC 2012


Author: mdounin
Date: 2012-05-11 13:19:22 +0000 (Fri, 11 May 2012)
New Revision: 4618
URL: http://trac.nginx.org/nginx/changeset/4618/nginx

Log:
Rewrite: fixed escaping and possible segfault (ticket #162).

The following code resulted in incorrect escaping of uri and possible
segfault:

    location / {
        rewrite ^(.*) $1?c=$1;
        return 200 "$uri";
    }

If there were arguments in a rewrite's replacement string, and length was
actually calculated (due to duplicate captures as in the example above,
or variables present), the is_args flag was set and incorrectly copied
after length calculation.  This resulted in escaping applied to the uri part
of the replacement, resulting in incorrect escaping.  Additionally, buffer
was allocated without escaping expected, thus this also resulted in buffer
overrun and possible segfault.


Modified:
   trunk/src/http/ngx_http_script.c

Modified: trunk/src/http/ngx_http_script.c
===================================================================
--- trunk/src/http/ngx_http_script.c	2012-05-11 13:14:58 UTC (rev 4617)
+++ trunk/src/http/ngx_http_script.c	2012-05-11 13:19:22 UTC (rev 4618)
@@ -1043,7 +1043,6 @@
         }
 
         e->buf.len = len;
-        e->is_args = le.is_args;
     }
 
     if (code->add_args && r->args.len) {



More information about the nginx-devel mailing list