Welcome! Log In Create A New Profile

Advanced

[PATCH] Fixing an obvious segfault in ngx_http_upstream

agentzh
April 30, 2010 11:46PM
Hi,

I ran into a segfault while debugging one of my modules due to a bug
in the ngx_http_upstream_create function. Here's the quick patch

diff -udTr nginx-0.8.36/src/http/ngx_http_upstream.c
nginx-0.8.36-patched/src/http/ngx_http_upstream.c
--- nginx-0.8.36/src/http/ngx_http_upstream.c 2010-01-30
00:45:14.000000000 +0800
+++ nginx-0.8.36-patched/src/http/ngx_http_upstream.c 2010-05-01
11:40:40.252227964 +0800
@@ -365,8 +365,6 @@
if (u && u->cleanup) {
r->main->count++;
ngx_http_upstream_cleanup(r);
- *u->cleanup = NULL;
- u->cleanup = NULL;
}

u = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_t));

That is, ngx_http_upstream_cleanup will also clear both *u->cleanup
and u->cleanup, so doing *u->cleanup = NULL again after the call will
cause segfault (writing to a NULL pointer). This issue exists in nginx
0.8.36 and as old as at 0.8.29 :)

Cheers,
-agentzh

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Fixing an obvious segfault in ngx_http_upstream

agentzh 2697 April 30, 2010 11:46PM

Re: [PATCH] Fixing an obvious segfault in ngx_http_upstream

Igor Sysoev 1074 May 03, 2010 03:12PM

Re: [PATCH] Fixing an obvious segfault in ngx_http_upstream

agentzh 1033 May 03, 2010 10:40PM

Re: [PATCH] Fixing an obvious segfault in ngx_http_upstream

Igor Sysoev 1148 May 05, 2010 03:40AM

Re: [PATCH] Fixing an obvious segfault in ngx_http_upstream

agentzh 1147 May 05, 2010 03:46AM

Re: [PATCH] Fixing an obvious segfault in ngx_http_upstream

Maxim Dounin 1040 May 05, 2010 05:20AM

Re: [PATCH] Fixing an obvious segfault in ngx_http_upstream

Igor Sysoev 1090 May 14, 2010 05:32AM

Re: [PATCH] Fixing an obvious segfault in ngx_http_upstream

Maxim Dounin 1002 May 14, 2010 08:40AM

Re: [PATCH] Fixing an obvious segfault in ngx_http_upstream

Igor Sysoev 1190 May 14, 2010 08:50AM

Re: [PATCH] Fixing an obvious segfault in ngx_http_upstream

agentzh 1274 June 07, 2010 05:40AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 267
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready