asyn-thrdd: item cleanup using resolv_id

Now that we support multiple async operations at the same transfer,
fix the thread queue cleanup to match not only the mid but also the
resolv_id.

Found by Codex Security

Closes #21202
This commit is contained in:
Stefan Eissing 2026-04-02 09:44:39 +02:00 committed by Daniel Stenberg
parent 33e43985b8
commit 99d5b90878
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -257,11 +257,16 @@ void Curl_async_thrdd_shutdown(struct Curl_easy *data,
Curl_async_thrdd_destroy(data, async);
}
struct async_thrdd_match_ctx {
uint32_t mid;
uint32_t resolv_id;
};
static bool async_thrdd_match_item(void *qitem, void *match_data)
{
struct Curl_easy *data = match_data;
const struct async_thrdd_match_ctx *ctx = match_data;
struct async_thrdd_item *item = qitem;
return item->mid == data->mid;
return (item->mid == ctx->mid) && (item->resolv_id == ctx->resolv_id);
}
void Curl_async_thrdd_destroy(struct Curl_easy *data,
@ -271,8 +276,11 @@ void Curl_async_thrdd_destroy(struct Curl_easy *data,
if(async->queries_ongoing && !async->done &&
data->multi && data->multi->resolv_thrdq) {
/* Remove any resolve items still queued */
struct async_thrdd_match_ctx mctx;
mctx.mid = data->mid;
mctx.resolv_id = async->id;
Curl_thrdq_clear(data->multi->resolv_thrdq,
async_thrdd_match_item, data);
async_thrdd_match_item, &mctx);
}
#ifdef USE_HTTPSRR_ARES
if(async->thrdd.rr.channel) {