Skip to content

Commit

Permalink
Fix phpGH-15937: stream timeout option overflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Sep 17, 2024
1 parent b26e610 commit 7275292
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions ext/standard/tests/streams/gh15937.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
GH-15937 (stream overflow on timeout setting)
--FILE--
<?php
$config = [
'http' => [
'timeout' => PHP_INT_MAX,
],
];
$ctx = stream_context_create($config);
var_dump(fopen("http://example.com", "r", false, $ctx));
?>
--EXPECTF--
resource(%d) of type (stream)
2 changes: 1 addition & 1 deletion main/php_network.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ PHPAPI int php_poll2(php_pollfd *ufds, unsigned int nfds, int timeout);
/* timeval-to-timeout (for poll(2)) */
static inline int php_tvtoto(struct timeval *timeouttv)
{
if (timeouttv) {
if (timeouttv && timeouttv->tv_sec >= 0 && timeouttv->tv_sec <= (INT_MAX / 1000)) {
return (timeouttv->tv_sec * 1000) + (timeouttv->tv_usec / 1000);
}
return -1;
Expand Down

0 comments on commit 7275292

Please sign in to comment.