Skip to content

Commit 4ad12bd

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
2 parents 2580883 + d828308 commit 4ad12bd

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed
+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)

main/php_network.h

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

0 commit comments

Comments
 (0)