]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
multi: Improve parameter check for curl_multi_remove_handle
authorJay Satiro <raysatiro@yahoo.com>
Tue, 17 Mar 2020 22:59:07 +0000 (18:59 -0400)
committerJay Satiro <raysatiro@yahoo.com>
Wed, 18 Mar 2020 06:58:42 +0000 (02:58 -0400)
- If an easy handle is owned by a multi different from the one specified
  then return CURLM_BAD_EASY_HANDLE.

Prior to this change I assume user error could cause corruption.

Closes https://github.com/curl/curl/pull/5116

docs/libcurl/libcurl-errors.3
lib/multi.c

index eff6544b6662566bbcf858f0e157be10c22c504c..3ea394e6937ab2aaa67d52dfd1d5ca3a555fc8b1 100644 (file)
@@ -283,8 +283,8 @@ Things are fine.
 The passed-in handle is not a valid CURLM handle.
 .IP "CURLM_BAD_EASY_HANDLE (2)"
 An easy handle was not good/valid. It could mean that it isn't an easy handle
-at all, or possibly that the handle already is in used by this or another
-multi handle.
+at all, or possibly that the handle already is in use by this or another multi
+handle.
 .IP "CURLM_OUT_OF_MEMORY (3)"
 You are doomed.
 .IP "CURLM_INTERNAL_ERROR (4)"
index e10e752931905c3c4fb2740213b6c3553ea3ce3e..d4f031873cca4143213e25299ae8c64bd6c62168 100644 (file)
@@ -700,6 +700,10 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
   if(!data->multi)
     return CURLM_OK; /* it is already removed so let's say it is fine! */
 
+  /* Prevent users from trying to remove an easy handle from the wrong multi */
+  if(data->multi != multi)
+    return CURLM_BAD_EASY_HANDLE;
+
   if(multi->in_callback)
     return CURLM_RECURSIVE_API_CALL;