asyn-thread: survive a c-ares channel set to NULL

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
This commit is contained in:
Daniel Stenberg 2025-02-07 16:40:53 +01:00
parent 17c287854b
commit 89ed161f56
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
2 changed files with 7 additions and 3 deletions

View File

@ -109,6 +109,9 @@ int Curl_ares_perform(ares_channel channel,
int i; int i;
int num = 0; int num = 0;
if(!channel)
return 0;
bitmask = ares_getsock(channel, socks, ARES_GETSOCK_MAXNUM); bitmask = ares_getsock(channel, socks, ARES_GETSOCK_MAXNUM);
for(i = 0; i < ARES_GETSOCK_MAXNUM; i++) { for(i = 0; i < ARES_GETSOCK_MAXNUM; i++) {

View File

@ -383,7 +383,8 @@ static void destroy_async_data(struct Curl_easy *data)
#endif #endif
#ifdef USE_HTTPSRR_ARES #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 #endif
/* /*
* if the thread is still blocking in the resolve syscall, detach it and * 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 #ifdef USE_HTTPSRR_ARES
if(resolve_httpsrr(data, asp)) if(resolve_httpsrr(data, asp))
goto err_exit; infof(data, "Failed HTTPS RR operation");
#endif #endif
return TRUE; return TRUE;
@ -670,7 +671,7 @@ int Curl_resolver_getsock(struct Curl_easy *data, curl_socket_t *socks)
#endif #endif
#ifdef USE_HTTPSRR_ARES #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); ret_val = Curl_ares_getsock(data, data->state.async.tdata->channel, socks);
for(socketi = 0; socketi < (MAX_SOCKSPEREASYHANDLE - 1); socketi++) for(socketi = 0; socketi < (MAX_SOCKSPEREASYHANDLE - 1); socketi++)
if(!ARES_GETSOCK_READABLE(ret_val, socketi) && if(!ARES_GETSOCK_READABLE(ret_val, socketi) &&