Skip to content

Commit

Permalink
Fix curl_multi_exec() overflow message (GH-17078)
Browse files Browse the repository at this point in the history
As is, passing `2147484` as `$timeout`, throws a `ValueError` stating
the `$timeout` needs to be between 0 and 2147484, what is a confusing.
Thus we report the proper threshold as float.

While we're at it we also drop the superfluous `(double)` cast, and
rely on C's usual arithmetic conversions.
  • Loading branch information
cmb69 authored Dec 13, 2024
1 parent a7cf072 commit bb6dbdc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ext/curl/multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ PHP_FUNCTION(curl_multi_select)

mh = Z_CURL_MULTI_P(z_mh);

if (!(timeout >= 0.0 && timeout <= ((double)INT_MAX / 1000.0))) {
zend_argument_value_error(2, "must be between 0 and %d", (int)ceilf((double)INT_MAX / 1000));
if (!(timeout >= 0.0 && timeout <= (INT_MAX / 1000.0))) {
zend_argument_value_error(2, "must be between 0 and %f", INT_MAX / 1000.0);
RETURN_THROWS();
}

Expand Down
4 changes: 2 additions & 2 deletions ext/curl/tests/gh15547.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ $mh = curl_multi_init();
var_dump(curl_multi_select($mh, 1000000));
?>
--EXPECTF--
curl_multi_select(): Argument #2 ($timeout) must be between %d and %d
curl_multi_select(): Argument #2 ($timeout) must be between %d and %d
curl_multi_select(): Argument #2 ($timeout) must be between %d and %f
curl_multi_select(): Argument #2 ($timeout) must be between %d and %f
int(0)

0 comments on commit bb6dbdc

Please sign in to comment.