diff options
author | Piotr Sikora <piotrsikora@google.com> | 2016-02-26 17:30:27 -0800 |
---|---|---|
committer | Piotr Sikora <piotrsikora@google.com> | 2016-02-26 17:30:27 -0800 |
commit | c3aed0a23392a509f64b740064f5f6633e8c89d8 (patch) | |
tree | 7eda6be9f9564655caad621664e24f1a06b4e0f5 /src/core/ngx_inet.c | |
parent | 030a1f959c9c673258fe53f968fab04fc9214b86 (diff) | |
download | nginx-c3aed0a23392a509f64b740064f5f6633e8c89d8.tar.gz nginx-c3aed0a23392a509f64b740064f5f6633e8c89d8.zip |
Core: allow strings without null-termination in ngx_parse_url().
This fixes buffer over-read while using variables in the "proxy_pass",
"fastcgi_pass", "scgi_pass", and "uwsgi_pass" directives, where result
of string evaluation isn't null-terminated.
Found with MemorySanitizer.
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Diffstat (limited to 'src/core/ngx_inet.c')
-rw-r--r-- | src/core/ngx_inet.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/core/ngx_inet.c b/src/core/ngx_inet.c index 96a04fded..3bbadb8b8 100644 --- a/src/core/ngx_inet.c +++ b/src/core/ngx_inet.c @@ -529,14 +529,16 @@ ngx_int_t ngx_parse_url(ngx_pool_t *pool, ngx_url_t *u) { u_char *p; + size_t len; p = u->url.data; + len = u->url.len; - if (ngx_strncasecmp(p, (u_char *) "unix:", 5) == 0) { + if (len >= 5 && ngx_strncasecmp(p, (u_char *) "unix:", 5) == 0) { return ngx_parse_unix_domain_url(pool, u); } - if (p[0] == '[') { + if (len && p[0] == '[') { return ngx_parse_inet6_url(pool, u); } |