[PATCH] Fix "$upstream_response_length" for upstream requests with buffering off
Piotr Sikora
piotr at cloudflare.com
Thu Apr 11 18:41:19 UTC 2013
Hey Maxim,
> The patch is wrong as u->pipe might not exists at all, and the
> code will result in null pointer dereference.
Argh, I was actually looking yesterday whether this might be the case,
but I didn't find a code path that would result in u->pipe not being
allocated... It seems that I totally forgot about memcached and my own
upstream modules... Good catch, thanks!
> Correct patch should be:
>
> --- a/src/http/ngx_http_upstream.c
> +++ b/src/http/ngx_http_upstream.c
> @@ -3307,7 +3307,7 @@ ngx_http_upstream_finalize_request(ngx_h
> u->state->response_sec = tp->sec - u->state->response_sec;
> u->state->response_msec = tp->msec - u->state->response_msec;
>
> - if (u->pipe) {
> + if (u->pipe && u->pipe->read_length) {
> u->state->response_length = u->pipe->read_length;
> }
> }
>
> Is it looks good for you?
Yeah, thanks!
Best regards,
Piotr Sikora
More information about the nginx-devel
mailing list