[PATCH]Fixed segmentation fault with error_page for 400 to named location

flygoast flygoast at 126.com
Fri Feb 21 16:40:35 UTC 2014


# HG changeset patch

# User FengGu <flygoast at 126.com>
# Date 1392981015 -28800
#          Fri Feb 21 19:10:15 2014 +0800
# Node ID 2dd8fd75f1646336b21cb2f4506f1d45b8771e56
# Parent  545a4d393e2fb8d5448dad89d25a110fa72e71d1
Fixed segmentation fault with error_page for 400 to named location


When using error_page for code 400 to named location, the bad request's uri
would be { 0, NULL }, it would result in segmentation fault in
ngx_http_index_handler() and so on.


diff -r 545a4d393e2f -r 2dd8fd75f164 src/http/ngx_http_core_module.c
--- a/src/http/ngx_http_core_module.c   Thu Feb 20 17:27:09 2014 +0400
+++ b/src/http/ngx_http_core_module.c   Fri Feb 21 19:10:15 2014 +0800
@@ -2651,6 +2651,12 @@
                            "using location: %V \"%V?%V\"",
                            name, &r->uri, &r->args);


+            if (r->uri.len == 0) {
+                ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
+                              "using \"/\" as uri for bad request");
+                ngx_str_set(&r->uri, "/");
+            }
+
             r->internal = 1;
             r->content_handler = NULL;
             r->uri_changed = 0;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20140222/598f95f2/attachment.html>


More information about the nginx-devel mailing list