From fed3e5e62f1460ca6419dfa15ee58c12f24e6ae1 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Sat, 25 Nov 2006 07:29:49 -0800 Subject: [PATCH] Fix error handling in dnsTimeoutHandler. This fixes a crash if a DNS query timeouts and cannot be resent, for example because the name server has crashed or the interface has been downed. Reported by Francesco Zappa. darcs-hash:20061125152949-4cc09-6817fcd6c51c44dccf9d0c700046911ce28a992d.gz --- dns.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/dns.c b/dns.c index 3b6e03b..38d34d5 100644 --- a/dns.c +++ b/dns.c @@ -804,33 +804,33 @@ dnsTimeoutHandler(TimeEventHandlerPtr event) query->timeout = MAX(10, query->timeout * 2); if(query->timeout > dnsMaxTimeout) { - removeQuery(query); abortObject(object, 501, internAtom("Timeout")); goto fail; } else { - query->timeout_handler = - scheduleTimeEvent(query->timeout, dnsTimeoutHandler, - sizeof(query), &query); - if(query->timeout_handler == NULL) { - do_log(L_ERROR, "Couldn't schedule DNS timeout handler.\n"); - abortObject(object, 501, - internAtom("Couldn't schedule DNS timeout handler")); - goto fail; - } rc = sendQuery(query); if(rc < 0) { - do_log(L_ERROR, "Couldn't send DNS query.\n"); if(rc != -EWOULDBLOCK && rc != -EAGAIN && rc != -ENOBUFS) { abortObject(object, 501, - internAtom("Couldn't send DNS query")); + internAtomError(-rc, + "Couldn't send DNS query")); goto fail; } /* else let it timeout */ } + query->timeout_handler = + scheduleTimeEvent(query->timeout, dnsTimeoutHandler, + sizeof(query), &query); + if(query->timeout_handler == NULL) { + do_log(L_ERROR, "Couldn't schedule DNS timeout handler.\n"); + abortObject(object, 501, + internAtom("Couldn't schedule DNS timeout handler")); + goto fail; + } return 1; } - - fail: + + fail: + removeQuery(query); object->flags &= ~OBJECT_INPROGRESS; if(query->inet4) releaseAtom(query->inet4); if(query->inet6) releaseAtom(query->inet6); -- 2.11.4.GIT