comparison src/http/ngx_http_upstream.c @ 7760:83c4622053b0

Upstream: fixed zero size buf alerts on extra data (ticket #2117). After 7675:9afa45068b8f and 7678:bffcc5af1d72 (1.19.1), during non-buffered simple proxying, responses with extra data might result in zero size buffers being generated and "zero size buf" alerts in writer. This bug is similar to the one with FastCGI proxying fixed in 7689:da8d758aabeb. In non-buffered mode, normally the filter function is not called if u->length is already 0, since u->length is checked after each call of the filter function. There is a case when this can happen though: if the response length is 0, and there are pre-read response body data left after reading response headers. As such, a check for u->length is needed at the start of non-buffered filter functions, similar to the one for p->length present in buffered filter functions. Appropriate checks added to the existing non-buffered copy filters in the upstream (used by scgi and uwsgi proxying) and proxy modules.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 12 Jan 2021 16:59:31 +0300
parents 7015f26aef90
children b1302f1dd2f6 13f7085b90d2
comparison
equal deleted inserted replaced
7759:a20eef9a1df2 7760:83c4622053b0
3719 ngx_chain_t *cl, **ll; 3719 ngx_chain_t *cl, **ll;
3720 ngx_http_upstream_t *u; 3720 ngx_http_upstream_t *u;
3721 3721
3722 u = r->upstream; 3722 u = r->upstream;
3723 3723
3724 if (u->length == 0) {
3725 ngx_log_error(NGX_LOG_WARN, r->connection->log, 0,
3726 "upstream sent more data than specified in "
3727 "\"Content-Length\" header");
3728 return NGX_OK;
3729 }
3730
3724 for (cl = u->out_bufs, ll = &u->out_bufs; cl; cl = cl->next) { 3731 for (cl = u->out_bufs, ll = &u->out_bufs; cl; cl = cl->next) {
3725 ll = &cl->next; 3732 ll = &cl->next;
3726 } 3733 }
3727 3734
3728 cl = ngx_chain_get_free_buf(r->pool, &u->free_bufs); 3735 cl = ngx_chain_get_free_buf(r->pool, &u->free_bufs);