]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
c-ares: when resolving failed, persist error
authorStefan Eissing <stefan@eissing.org>
Fri, 10 Oct 2025 08:40:55 +0000 (10:40 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 10 Oct 2025 21:49:27 +0000 (23:49 +0200)
Repeated calls to `Curl_async_is_resolved()` after a failure
returned OK and not the error that was the result of the resolve
fail.

Reported-by: Joshua Rogers
Closes #18999

lib/asyn-ares.c

index dcbed0129c739fa59c62447a2fc343169b8cacda..d39db23a7bdb0d9ec353891fb227d19de1dec8a1 100644 (file)
@@ -302,11 +302,13 @@ CURLcode Curl_async_is_resolved(struct Curl_easy *data,
 
   if(data->state.async.done) {
     *dns = data->state.async.dns;
-    return CURLE_OK;
+    return ares->result;
   }
 
-  if(Curl_ares_perform(ares->channel, 0) < 0)
-    return CURLE_UNRECOVERABLE_POLL;
+  if(Curl_ares_perform(ares->channel, 0) < 0) {
+    result = CURLE_UNRECOVERABLE_POLL;
+    goto out;
+  }
 
 #ifndef HAVE_CARES_GETADDRINFO
   /* Now that we have checked for any last minute results above, see if there
@@ -371,6 +373,9 @@ CURLcode Curl_async_is_resolved(struct Curl_easy *data,
                  result, *dns ? "" : "not ");
     async_ares_cleanup(data);
   }
+
+out:
+  ares->result = result;
   return result;
 }