Skip to content

Commit

Permalink
Upstream: fixed u->headers_in.headers allocation error handling.
Browse files Browse the repository at this point in the history
Previously, an allocation error resulted in uninitialized memory access
when evaluating $upstream_http_ variables.

On a related note, see r->headers_out.headers cleanup work in 0cdee26605f3.
  • Loading branch information
pluknet committed May 18, 2017
1 parent 84fdff7 commit 9359155
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/http/modules/ngx_http_fastcgi_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1878,6 +1878,7 @@ ngx_http_fastcgi_process_header(ngx_http_request_t *r)

p = ngx_pnalloc(r->pool, size);
if (p == NULL) {
h->hash = 0;
return NGX_ERROR;
}

Expand All @@ -1900,6 +1901,7 @@ ngx_http_fastcgi_process_header(ngx_http_request_t *r)
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
"invalid header after joining "
"FastCGI records");
h->hash = 0;
return NGX_ERROR;
}

Expand All @@ -1925,6 +1927,7 @@ ngx_http_fastcgi_process_header(ngx_http_request_t *r)
h->key.len + 1 + h->value.len + 1
+ h->key.len);
if (h->key.data == NULL) {
h->hash = 0;
return NGX_ERROR;
}

Expand Down
1 change: 1 addition & 0 deletions src/http/modules/ngx_http_proxy_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1798,6 +1798,7 @@ ngx_http_proxy_process_header(ngx_http_request_t *r)
h->key.data = ngx_pnalloc(r->pool,
h->key.len + 1 + h->value.len + 1 + h->key.len);
if (h->key.data == NULL) {
h->hash = 0;
return NGX_ERROR;
}

Expand Down
1 change: 1 addition & 0 deletions src/http/modules/ngx_http_scgi_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,7 @@ ngx_http_scgi_process_header(ngx_http_request_t *r)
h->key.len + 1 + h->value.len + 1
+ h->key.len);
if (h->key.data == NULL) {
h->hash = 0;
return NGX_ERROR;
}

Expand Down
1 change: 1 addition & 0 deletions src/http/modules/ngx_http_uwsgi_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,7 @@ ngx_http_uwsgi_process_header(ngx_http_request_t *r)
h->key.len + 1 + h->value.len + 1
+ h->key.len);
if (h->key.data == NULL) {
h->hash = 0;
return NGX_ERROR;
}

Expand Down

0 comments on commit 9359155

Please sign in to comment.