cURL / Mailing Lists / curl-library / Single Mail

curl-library

Should check for CURLE_COULDNT_RESOLVE_HOST

From: Siddhartha Prakash Jain <spjain_at_in.firstrain.com>
Date: Fri, 14 Nov 2003 16:03:42 +0530

Hi,
        In Curl_resolv we do the following:
          if (!dns) {
    /* The entry was not in the cache. Resolve it to IP address */
      
    /* If my_getaddrinfo() returns NULL, 'wait' might be set to a non-zero
       value indicating that we need to wait for the response to the resolve
       call */
    Curl_addrinfo *addr = my_getaddrinfo(conn, hostname, port, &wait);
    
    if (!addr) {
      if(wait) {
        /* the response to our resolve call will come asynchronously at
           a later time, good or bad */
        /* First, check that we haven't received the info by now */
        (void)Curl_is_resolved(conn, &dns);
        if(dns)
          rc = 0; /* pointer provided */
        else
          rc = 1; /* no info yet */
      }
    }

        We should check for the return value of Curl_is_resolved. Sometimes if the url to fetch has an ip address and that ip address is not correct say something like 190.222.22.22222 then Curl_is_resolved returns error CURLE_COULDNT_RESOLVE_HOST but we ignore that and set rc = 1.

        In my code, I was tryin to fix some memory leaks by calling ares_destroy after conn->async.done is true, I got a crash on a url that has such an ip.

        Taking note of the return value solves the problem. This is what I did:
        CURLcode retcode = Curl_is_resolved(conn, &dns);
        if(dns || retcode == CURLE_COULDNT_RESOLVE_HOST)
          rc = 0; /* pointer provided */
        else
          rc = 1; /* no info yet */

        I am still working on the memory issue but I think that check on the return value is relevant independent of that.
        
Thanks,
Siddhartha.
        
        

-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
Received on 2003-11-14