]> git.kaiwu.me - nginx.git/commit
Upstream: fixed SIGSEGV with the "if" directive.
authorMaxim Dounin <mdounin@mdounin.ru>
Thu, 13 Dec 2012 16:05:59 +0000 (16:05 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Thu, 13 Dec 2012 16:05:59 +0000 (16:05 +0000)
commit658296290cc1be3739f0092d5afe719df5a88d82
treec8fa772a7c77092b01a834a23804d85219c01d34
parentba290091cf2c369ae36c6c3845f770f85f1172e6
Upstream: fixed SIGSEGV with the "if" directive.

Configuration like

    location / {
        set $true 1;

        if ($true) {
            proxy_pass http://backend;
        }

        if ($true) {
            # nothing
        }
    }

resulted in segmentation fault due to NULL pointer dereference as the
upstream configuration wasn't initialized in an implicit location created
by the last if(), but the r->content_handler was set due to first if().

Instead of committing a suicide by dereferencing a NULL pointer, return
500 (Internal Server Error) in such cases, i.e. if uscf is NULL.  Better
fix would be to avoid such cases by fixing the "if" directive handling,
but it's out of scope of this patch.

Prodded by Piotr Sikora.
src/http/ngx_http_upstream.c