curl-library
PATCH - alarm()-based DNS timeout bug?
Date: Mon, 22 Mar 2010 12:40:04 -0700
Hey there,
I have attached a piece of code that demonstrates the problem for me on
Red Hat Linux 4.x. If everything goes well and the signal handler for
SIGALRM is correctly removed, the output is as follows:
Result is 0
sa_handler is 0x(nil)
sa_sigaction is 0x(nil)
In case of a DNS timeout the output is as follows, so the signal handler
is still around, which is bad:
Result is 6
sa_handler is 0x0x52f5c0
sa_sigaction is 0x0x52f5c0
To trigger a DNS timeout I simply removed the legitimate name server
from /etc/resolv.conf and replaced it by "3.0.0.0".
The attached patch (against 7.20.0) is straight forward. We need to jump
to the clean-up code right after Curl_resolv() in case of a timeout. I
have also moved the call to sigsetjmp() further down in the code so that
it is the last thing that we do before calling Curl_resolv(). We would
otherwise have to declare any variables that we modify after the
sigsetjmp() (such as "keep_sigact") as "volatile".
Looks like this bug was introduced in 7.19.1 when the call to
sigsetjmp() was pulled up from Curl_resolv().
Thomas
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
- text/x-csrc attachment: curl-bug.c
- text/x-patch attachment: curl-bug-7.20.0.diff