Mercurial > hg > nginx-quic
comparison src/http/modules/perl/nginx.xs @ 6986:0cdee26605f3
Cleaned up r->headers_out.headers allocation error handling.
If initialization of a header failed for some reason after ngx_list_push(),
leaving the header as is can result in uninitialized memory access by
the header filter or the log module. The fix is to clear partially
initialized headers in case of errors.
For the Cache-Control header, the fix is to postpone pushing
r->headers_out.cache_control until its value is completed.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 20 Apr 2017 18:26:37 +0300 |
parents | 1c5e5e5b008d |
children | 36c52a0f6ded |
comparison
equal
deleted
inserted
replaced
6985:23ecffd5bcfe | 6986:0cdee26605f3 |
---|---|
508 } | 508 } |
509 | 509 |
510 header->hash = 1; | 510 header->hash = 1; |
511 | 511 |
512 if (ngx_http_perl_sv2str(aTHX_ r, &header->key, key) != NGX_OK) { | 512 if (ngx_http_perl_sv2str(aTHX_ r, &header->key, key) != NGX_OK) { |
513 header->hash = 0; | |
513 XSRETURN_EMPTY; | 514 XSRETURN_EMPTY; |
514 } | 515 } |
515 | 516 |
516 if (ngx_http_perl_sv2str(aTHX_ r, &header->value, value) != NGX_OK) { | 517 if (ngx_http_perl_sv2str(aTHX_ r, &header->value, value) != NGX_OK) { |
518 header->hash = 0; | |
517 XSRETURN_EMPTY; | 519 XSRETURN_EMPTY; |
518 } | 520 } |
519 | 521 |
520 if (header->key.len == sizeof("Content-Length") - 1 | 522 if (header->key.len == sizeof("Content-Length") - 1 |
521 && ngx_strncasecmp(header->key.data, (u_char *) "Content-Length", | 523 && ngx_strncasecmp(header->key.data, (u_char *) "Content-Length", |