]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
asyn-thread: survive a c-ares channel set to NULL
authorDaniel Stenberg <daniel@haxx.se>
Fri, 7 Feb 2025 15:40:53 +0000 (16:40 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 9 Feb 2025 10:30:08 +0000 (11:30 +0100)
When the c-ares setup fails and we get a NULL channel, the resolve still
continues and we just need to survive it and just not get any HTTPS RR.

Reported-by: nono303 on github
Fixes #16216
Closes #16244

lib/asyn-ares.c
lib/asyn-thread.c

index 38dc729e04d8909bc898a8f3d84f42f461aef132..640c8a9b653489ad0712a9b06860d356ef9a87f4 100644 (file)
@@ -109,6 +109,9 @@ int Curl_ares_perform(ares_channel channel,
   int i;
   int num = 0;
 
+  if(!channel)
+    return 0;
+
   bitmask = ares_getsock(channel, socks, ARES_GETSOCK_MAXNUM);
 
   for(i = 0; i < ARES_GETSOCK_MAXNUM; i++) {
index eb80bc35e98cc583e96900cb91e34270b1eb9fb5..f98941596eb0a61b1e51f6177b84c59323580d43 100644 (file)
@@ -383,7 +383,8 @@ static void destroy_async_data(struct Curl_easy *data)
 #endif
 
 #ifdef USE_HTTPSRR_ARES
-    ares_destroy(data->state.async.tdata->channel);
+    if(data->state.async.tdata->channel)
+      ares_destroy(data->state.async.tdata->channel);
 #endif
     /*
      * if the thread is still blocking in the resolve syscall, detach it and
@@ -490,7 +491,7 @@ static bool init_resolve_thread(struct Curl_easy *data,
   }
 #ifdef USE_HTTPSRR_ARES
   if(resolve_httpsrr(data, asp))
-    goto err_exit;
+    infof(data, "Failed HTTPS RR operation");
 #endif
   return TRUE;
 
@@ -670,7 +671,7 @@ int Curl_resolver_getsock(struct Curl_easy *data, curl_socket_t *socks)
 #endif
 
 #ifdef USE_HTTPSRR_ARES
-  if(data->state.async.tdata) {
+  if(data->state.async.tdata && data->state.async.tdata->channel) {
     ret_val = Curl_ares_getsock(data, data->state.async.tdata->channel, socks);
     for(socketi = 0; socketi < (MAX_SOCKSPEREASYHANDLE - 1); socketi++)
       if(!ARES_GETSOCK_READABLE(ret_val, socketi) &&