-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fixed GH-15547: curl_multi_wait expects a signed int for timeout. #15548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -187,7 +187,12 @@ PHP_FUNCTION(curl_multi_select) | |
|
||
mh = Z_CURL_MULTI_P(z_mh); | ||
|
||
error = curl_multi_wait(mh->multi, NULL, 0, (unsigned long) (timeout * 1000.0), &numfds); | ||
if (!(timeout >= ((double)INT_MIN / 1000.0) && timeout <= ((double)INT_MAX / 1000.0))) { | ||
php_error_docref(NULL, E_WARNING, "timeout must be between %d and %d", (INT_MIN / 1000), (INT_MAX / 1000)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This appears to be slightly off due to rounding. Should probably be something like And I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops! Of course, throwing a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might make sense to add support for docrefs for all argument exceptions and ZPP failures. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There is a problem, though, since ZPP is part of the Zend engine, and
Yeah, but I didn't mean the docref param, but was referring to the general mechanism, which is nice, e.g. https://3v4l.org/deO0B. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah right... I agree that Maybe we should introduce a function pointer API similar to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, already forgot about the And yes, a function pointer could solve the issue nicely. And we should probably use some tooling to detect such circular dependencies. |
||
RETURN_LONG(-1); | ||
} | ||
|
||
error = curl_multi_wait(mh->multi, NULL, 0, (int) (timeout * 1000.0), &numfds); | ||
if (CURLM_OK != error) { | ||
SAVE_CURLM_ERROR(mh, error); | ||
RETURN_LONG(-1); | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,19 @@ | ||||||
--TEST-- | ||||||
GH-15547 - overflow on timeout argument | ||||||
--EXTENSIONS-- | ||||||
curl | ||||||
--FILE-- | ||||||
<?php | ||||||
|
||||||
$mh = curl_multi_init(); | ||||||
var_dump(curl_multi_select($mh, -2500000)); | ||||||
cmb69 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
var_dump(curl_multi_select($mh, 2500000)); | ||||||
var_dump(curl_multi_select($mh, 1000000)); | ||||||
?> | ||||||
--EXPECTF-- | ||||||
Warning: curl_multi_select(): timeout must be between %s and %s in %s on line %d | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Suggested change
|
||||||
int(-1) | ||||||
|
||||||
Warning: curl_multi_select(): timeout must be between %s and %s in %s on line %d | ||||||
int(-1) | ||||||
int(0) |
Uh oh!
There was an error while loading. Please reload this page.