From bb6dbdcf94ef090249dfd0890afb5c97f8902599 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Fri, 13 Dec 2024 16:06:39 +0100 Subject: [PATCH] Fix curl_multi_exec() overflow message (GH-17078) 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. --- ext/curl/multi.c | 4 ++-- ext/curl/tests/gh15547.phpt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/curl/multi.c b/ext/curl/multi.c index 6456cf6f813..938393f410e 100644 --- a/ext/curl/multi.c +++ b/ext/curl/multi.c @@ -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(); } diff --git a/ext/curl/tests/gh15547.phpt b/ext/curl/tests/gh15547.phpt index cee3f00cdb9..489fdd0b999 100644 --- a/ext/curl/tests/gh15547.phpt +++ b/ext/curl/tests/gh15547.phpt @@ -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)