Skip to content

Commit c4ae645

Browse files
committed
Follow-up on GH-15548: curl_multi_select.
throws a ValueError on timeout overflow. close GH-15594
1 parent 8f3dc78 commit c4ae645

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

UPGRADING

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,10 @@ PHP 8.4 UPGRADE NOTES
574574
. trigger_error() and user_error() now have a return type of true instead of
575575
bool.
576576

577+
- Curl:
578+
. curl_multi_select throws a ValueError if the timeout argument if it's negative
579+
or greater than PHP_INT_MAX.
580+
577581
- DOM:
578582
. DOMDocument::registerNodeClass() now has a tentative return type of true.
579583
Previously, the return type was bool but only true could be returned in practice.

ext/curl/multi.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,8 @@ PHP_FUNCTION(curl_multi_select)
188188
mh = Z_CURL_MULTI_P(z_mh);
189189

190190
if (!(timeout >= 0.0 && timeout <= ((double)INT_MAX / 1000.0))) {
191-
php_error_docref(NULL, E_WARNING, "timeout must be between 0 and %d", (int)ceilf((double)INT_MAX / 1000));
192-
#ifdef CURLM_BAD_FUNCTION_ARGUMENT
193-
SAVE_CURLM_ERROR(mh, CURLM_BAD_FUNCTION_ARGUMENT);
194-
#endif
195-
RETURN_LONG(-1);
191+
zend_argument_value_error(2, "must be between 0 and %d", (int)ceilf((double)INT_MAX / 1000));
192+
RETURN_THROWS();
196193
}
197194

198195
error = curl_multi_wait(mh->multi, NULL, 0, (int) (timeout * 1000.0), &numfds);

ext/curl/tests/gh15547.phpt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@ curl
66
<?php
77

88
$mh = curl_multi_init();
9-
var_dump(curl_multi_select($mh, -2500000));
10-
var_dump(curl_multi_strerror(curl_multi_errno($mh)));
9+
10+
try {
11+
curl_multi_select($mh, -2500000);
12+
} catch (\ValueError $e) {
13+
echo $e->getMessage() . PHP_EOL;
14+
}
1115
curl_multi_close($mh);
1216
$mh = curl_multi_init();
13-
var_dump(curl_multi_select($mh, 2500000));
14-
var_dump(curl_multi_strerror(curl_multi_errno($mh)));
17+
try {
18+
curl_multi_select($mh, 2500000);
19+
} catch (\ValueError $e) {
20+
echo $e->getMessage() . PHP_EOL;
21+
}
1522
curl_multi_close($mh);
1623
$mh = curl_multi_init();
1724
var_dump(curl_multi_select($mh, 1000000));
18-
var_dump(curl_multi_strerror(curl_multi_errno($mh)));
1925
?>
2026
--EXPECTF--
21-
Warning: curl_multi_select(): timeout must be between 0 and %d in %s on line %d
22-
int(-1)
23-
%s
24-
25-
Warning: curl_multi_select(): timeout must be between 0 and %d in %s on line %d
26-
int(-1)
27-
%s
27+
curl_multi_select(): Argument #2 ($timeout) must be between %d and %d
28+
curl_multi_select(): Argument #2 ($timeout) must be between %d and %d
2829
int(0)
29-
string(8) "No error"

0 commit comments

Comments
 (0)