RE: PATCH: Fix for crash in c-ares
Date: Thu, 24 May 2007 10:17:03 -0400
> From: curl-library-bounces_at_cool.haxx.se
> [mailto:curl-library-bounces_at_cool.haxx.se] On Behalf Of
> Daniel Stenberg
> Sent: Wednesday, May 23, 2007 5:19 PM
> To: libcurl development
> Subject: Re: PATCH: Fix for crash in c-ares
> On Mon, 21 May 2007, Ravi Pratap wrote:
> > Here's a patch for a crash in c-ares on init, on a host that has no
> > network adapter, or has its cable unplugged. The crash really is
> > related to the status variable not being initialized
> properly in that code path.
> That patch puzzles me. If 'status' wasn't set properly
> previously, then won't the if line on line 740 be weird? I
> mean if the init is the problem, shouldn't the fix be in the init?
Here's an updated patch.
The problem was that in the Windows codepath, status was left as -1 on
exit, causing ares_strerror to segfault on accessing an array index of
-1. This fixes the problem the right way, IMHO.
RCS file: /cvsroot/curl/curl/ares/ares_init.c,v
retrieving revision 1.51
diff -u -r1.51 ares_init.c
--- ares/ares_init.c 26 Feb 2007 04:33:19 -0000 1.51
+++ ares/ares_init.c 24 May 2007 14:15:00 -0000
@@ -555,6 +555,10 @@
if (status == ARES_SUCCESS)
status = ARES_EOF;
+ /* Catch the case when all the above checks fail (which happens
+ when there is no network card or the cable is unplugged) */
+ status = ARES_EFILE;
Received on 2007-05-24