Skip to content

Commit d828308

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
2 parents a17634c + 332b067 commit d828308

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

Diff for: ext/standard/tests/streams/gh15937.phpt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
GH-15937 (stream overflow on timeout setting)
3+
--SKIPIF--
4+
<?php if (getenv("SKIP_ONLINE_TESTS")) die("skip online test"); ?>
5+
--FILE--
6+
<?php
7+
$config = [
8+
'http' => [
9+
'timeout' => PHP_INT_MAX,
10+
],
11+
];
12+
$ctx = stream_context_create($config);
13+
var_dump(fopen("http://www.example.com", "r", false, $ctx));
14+
?>
15+
--EXPECTF--
16+
resource(%d) of type (stream)

Diff for: main/php_network.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ PHPAPI int php_poll2(php_pollfd *ufds, unsigned int nfds, int timeout);
162162
/* timeval-to-timeout (for poll(2)) */
163163
static inline int php_tvtoto(struct timeval *timeouttv)
164164
{
165-
if (timeouttv) {
165+
if (timeouttv && timeouttv->tv_sec >= 0 && timeouttv->tv_sec <= ((INT_MAX - 1000) / 1000)) {
166166
return (timeouttv->tv_sec * 1000) + (timeouttv->tv_usec / 1000);
167167
}
168168
return -1;

0 commit comments

Comments
 (0)