Skip to content

Commit

Permalink
Core: allow strings without null-termination in ngx_parse_url().
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
PiotrSikora committed Feb 27, 2016
1 parent 030a1f9 commit c3aed0a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/ngx_inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit c3aed0a

Please sign in to comment.