1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix GH-15937: stream timeout option overflow.

close GH-15942
This commit is contained in:
David Carlier
2024-09-17 19:43:42 +01:00
parent f5649556ea
commit 332b067c5e
3 changed files with 19 additions and 1 deletions

2
NEWS
View File

@@ -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).

View File

@@ -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)

View File

@@ -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;