From: Stefan Eissing Date: Wed, 10 Sep 2025 09:33:36 +0000 (+0200) Subject: easy_getinfo: check magic, Curl_close safety X-Git-Tag: rc-8_17_0-1~416 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=80ac5fb2ec29203fd9d87d705f72e8cd2afee501;p=thirdparty%2Fcurl.git easy_getinfo: check magic, Curl_close safety Check the easy handles magic in calls to curl_easy_getinfo(). In Curl_close() clear the magic after DNS shutdown since we'd like to see tracing for this. When clearing the magic, also clear the verbose flag so we no longer call DEBUGFUNCTION on such a handle. Closes #18511 --- diff --git a/lib/easy.c b/lib/easy.c index b9b8d52754..0a4b6faf52 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -877,12 +877,16 @@ void curl_easy_cleanup(CURL *ptr) * information from a performed transfer and similar. */ #undef curl_easy_getinfo -CURLcode curl_easy_getinfo(CURL *data, CURLINFO info, ...) +CURLcode curl_easy_getinfo(CURL *easy, CURLINFO info, ...) { + struct Curl_easy *data = easy; va_list arg; void *paramp; CURLcode result; + if(!GOOD_EASY_HANDLE(data)) + return CURLE_BAD_FUNCTION_ARGUMENT; + va_start(arg, info); paramp = va_arg(arg, void *); diff --git a/lib/url.c b/lib/url.c index b52267cb67..45d44bac73 100644 --- a/lib/url.c +++ b/lib/url.c @@ -258,13 +258,20 @@ CURLcode Curl_close(struct Curl_easy **datap) Curl_expire_clear(data); /* shut off any timers left */ - data->magic = 0; /* force a clear AFTER the possibly enforced removal from - the multi handle, since that function uses the magic - field! */ - if(data->state.rangestringalloc) free(data->state.range); + /* release any resolve information this transfer kept */ + Curl_async_destroy(data); + Curl_resolv_unlink(data, &data->state.dns[0]); /* done with this */ + Curl_resolv_unlink(data, &data->state.dns[1]); + + data->set.verbose = FALSE; /* no more calls to DEBUGFUNCTION */ + data->magic = 0; /* force a clear AFTER the possibly enforced removal from + * the multi handle and async dns shutdown. The multi + * handle might check the magic and so might any + * DEBUGFUNCTION invoked for tracing */ + /* freed here just in case DONE was not called */ Curl_req_free(&data->req, data); @@ -299,11 +306,6 @@ CURLcode Curl_close(struct Curl_easy **datap) Curl_safefree(data->info.contenttype); Curl_safefree(data->info.wouldredirect); - /* release any resolve information this transfer kept */ - Curl_async_destroy(data); - Curl_resolv_unlink(data, &data->state.dns[0]); /* done with this */ - Curl_resolv_unlink(data, &data->state.dns[1]); - data_priority_cleanup(data); /* No longer a dirty share, if it exists */