Skip to content

Commit

Permalink
Fix GH-15937: stream timeout option overflow.
Browse files Browse the repository at this point in the history
close GH-15942
  • Loading branch information
devnexen committed Sep 30, 2024
1 parent f564955 commit 332b067
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ PHP NEWS
- Standard:
. Fixed bug GH-15613 (overflow on unpack call hex string repeater).
(David Carlier)
. Fixed bug GH-15937 (overflow on stream timeout option value).
(David Carlier)

- Streams:
. Fixed bugs GH-15908 and GH-15026 (leak / assertion failure in streams.c).
Expand Down
16 changes: 16 additions & 0 deletions ext/standard/tests/streams/gh15937.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
GH-15937 (stream overflow on timeout setting)
--SKIPIF--
<?php if (getenv("SKIP_ONLINE_TESTS")) die("skip online test"); ?>
--FILE--
<?php
$config = [
'http' => [
'timeout' => PHP_INT_MAX,
],
];
$ctx = stream_context_create($config);
var_dump(fopen("http://www.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) / 1000)) {
return (timeouttv->tv_sec * 1000) + (timeouttv->tv_usec / 1000);
}
return -1;
Expand Down

0 comments on commit 332b067

Please sign in to comment.