multi: check that the multi handle is valid in curl_multi_assign

By requiring that the multi handle is fine, it can detect bad usage
better and by that avoid crashes. Like in the #14860 case, which is an
application calling curl_multi_assign() with a NULL pointer multi
handle.

Reported-by: Carlo Cabrera
Fixes #14860
Closes #14862
This commit is contained in:
Daniel Stenberg 2024-09-11 14:12:41 +02:00
parent 30865e09b7
commit 48f61e781a
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -3688,6 +3688,8 @@ CURLMcode curl_multi_assign(struct Curl_multi *multi, curl_socket_t s,
void *hashp)
{
struct Curl_sh_entry *there = NULL;
if(!GOOD_MULTI_HANDLE(multi))
return CURLM_BAD_HANDLE;
there = sh_getentry(&multi->sockhash, s);