]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
multi: Change curl_multi_wait/poll to error on negative timeout
authorJay Satiro <raysatiro@yahoo.com>
Sat, 28 Dec 2019 04:39:24 +0000 (23:39 -0500)
committerJay Satiro <raysatiro@yahoo.com>
Sat, 11 Jan 2020 23:16:28 +0000 (18:16 -0500)
- Add new error CURLM_BAD_FUNCTION_ARGUMENT and return that error when
  curl_multi_wait/poll is passed timeout param < 0.

Prior to this change passing a negative value to curl_multi_wait/poll
such as -1 could cause the function to wait forever.

Reported-by: hamstergene@users.noreply.github.com
Fixes https://github.com/curl/curl/issues/4763

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

docs/libcurl/libcurl-errors.3
docs/libcurl/symbols-in-versions
include/curl/multi.h
lib/multi.c
lib/strerror.c
packages/OS400/curl.inc.in
tests/data/test1538

index 0305af43e1fc679179d066b010297628517e5053..ac06f27c711c430a56e79b409a301778fde7b33b 100644 (file)
@@ -147,7 +147,7 @@ Function not found. A required zlib function was not found.
 .IP "CURLE_ABORTED_BY_CALLBACK (42)"
 Aborted by callback. A callback returned "abort" to libcurl.
 .IP "CURLE_BAD_FUNCTION_ARGUMENT (43)"
-Internal error. A function was called with a bad parameter.
+A function was called with a bad parameter.
 .IP "CURLE_INTERFACE_FAILED (45)"
 Interface error. A specified outgoing interface could not be used. Set which
 interface to use for outgoing connections' source IP address with
@@ -299,6 +299,8 @@ second time. (Added in 7.32.1)
 An API function was called from inside a callback.
 .IP "CURLM_WAKEUP_FAILURE (9)"
 Wakeup is unavailable or failed.
+.IP "CURLM_BAD_FUNCTION_ARGUMENT (10)"
+A function was called with a bad parameter.
 .SH "CURLSHcode"
 The "share" interface will return a CURLSHcode to indicate when an error has
 occurred.  Also consider \fIcurl_share_strerror(3)\fP.
index b9cf71cc2a28ad9d8c2a672e40f6e93f1767c0b8..7a80785572722cc79276a2e0220c273486f37829 100644 (file)
@@ -334,6 +334,7 @@ CURLMSG_DONE                    7.9.6
 CURLMSG_NONE                    7.9.6
 CURLM_ADDED_ALREADY             7.32.1
 CURLM_BAD_EASY_HANDLE           7.9.6
+CURLM_BAD_FUNCTION_ARGUMENT     7.69.0
 CURLM_BAD_HANDLE                7.9.6
 CURLM_BAD_SOCKET                7.15.4
 CURLM_CALL_MULTI_PERFORM        7.9.6
index 21d8407b512ad736713a7a5a90cd9fbaff26573b..bda9bb7b816c400e2cde1795f4dae8937afbfd0a 100644 (file)
@@ -72,7 +72,8 @@ typedef enum {
                             attempted to get added - again */
   CURLM_RECURSIVE_API_CALL, /* an api function was called from inside a
                                callback */
-  CURLM_WAKEUP_FAILURE, /* wakeup is unavailable or failed */
+  CURLM_WAKEUP_FAILURE,  /* wakeup is unavailable or failed */
+  CURLM_BAD_FUNCTION_ARGUMENT,  /* function called with a bad parameter */
   CURLM_LAST
 } CURLMcode;
 
index 6d819b4aaa7bad8505d441eea96be44f0f0ad83f..31275ca2b72d8766c215986f0f42bd45d379e850 100644 (file)
@@ -1048,6 +1048,9 @@ static CURLMcode Curl_multi_wait(struct Curl_multi *multi,
   if(multi->in_callback)
     return CURLM_RECURSIVE_API_CALL;
 
+  if(timeout_ms < 0)
+    return CURLM_BAD_FUNCTION_ARGUMENT;
+
   /* Count up how many fds we have from the multi handle */
   data = multi->easyp;
   while(data) {
index 29df5aa55a9467a740dc07bf165aae7db8fa4817..a7b76180066c14a6c77385c8d7e713fa38f3bb04 100644 (file)
@@ -392,6 +392,9 @@ curl_multi_strerror(CURLMcode error)
   case CURLM_WAKEUP_FAILURE:
     return "Wakeup is unavailable or failed";
 
+  case CURLM_BAD_FUNCTION_ARGUMENT:
+    return "A libcurl function was given a bad argument";
+
   case CURLM_LAST:
     break;
   }
index 4e34de16236b4ce73e919de68408ed9ed67616f9..e5454daa1fe22a8c53718879549730eb495d53dc 100644 (file)
      d                 c                   8
      d  CURLM_WAKEUP_FAILURE...
      d                 c                   9
-     d  CURLM_LAST     c                   10
+     d  CURLM_BAD_FUNCTION_ARGUMENT...
+     d                 c                   10
+     d  CURLM_LAST     c                   11
       *
      d CURLMSG         s             10i 0 based(######ptr######)               Enum
      d  CURLMSG_NONE   c                   0
index 3b22ebc27376273339cd7a2661d72a41ff3b5447..c96983061f9d802d334f841fb80761ae92e98288 100644 (file)
@@ -140,7 +140,8 @@ m6: Unknown option
 m7: The easy handle is already added to a multi handle
 m8: API function called from within callback
 m9: Wakeup is unavailable or failed
-m10: Unknown error
+m10: A libcurl function was given a bad argument
+m11: Unknown error
 s0: No error
 s1: Unknown share option
 s2: Share currently in use