]> git.kaiwu.me - nginx.git/commitdiff
Core: fixed port handling in ngx_parse_inet6_url().
authorValentin Bartenev <vbart@nginx.com>
Wed, 11 May 2016 14:55:20 +0000 (17:55 +0300)
committerValentin Bartenev <vbart@nginx.com>
Wed, 11 May 2016 14:55:20 +0000 (17:55 +0300)
This fixes buffer over-read when no port is specified in cases
similar to 5df5d7d771f6, and catches missing port separator.

src/core/ngx_inet.c

index 33b303dd06510502a31946b539ced8835e53bd41..d5b7cf96a1ff904ae4c62994b5da7c468c6a4118 100644 (file)
@@ -861,7 +861,12 @@ ngx_parse_inet6_url(ngx_pool_t *pool, ngx_url_t *u)
             last = uri;
         }
 
-        if (*port == ':') {
+        if (port < last) {
+            if (*port != ':') {
+                u->err = "invalid host";
+                return NGX_ERROR;
+            }
+
             port++;
 
             len = last - port;