Skip to content

Commit 94d9cc1

Browse files
committed
Merge branch 'PHP-8.4'
2 parents 0373157 + 986dfd4 commit 94d9cc1

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

ext/sockets/sockets.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,11 @@ char *sockets_strerror(int error) /* {{{ */
370370

371371
#ifndef PHP_WIN32
372372
if (error < -10000) {
373-
error = -error - 10000;
373+
if (error == INT_MIN) {
374+
error = 2147473648;
375+
} else {
376+
error = -error - 10000;
377+
}
374378

375379
#ifdef HAVE_HSTRERROR
376380
buf = hstrerror(error);

ext/sockets/tests/gh16267.phpt

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,16 @@ GH-16267 - overflow on socket_strerror argument
33
--EXTENSIONS--
44
sockets
55
--SKIPIF--
6-
<?php if (PHP_INT_SIZE != 8) die('skip 64-bit only'); ?>
6+
<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?>
77
--FILE--
88
<?php
9+
var_dump(socket_strerror(-2147483648));
910
try {
10-
socket_strerror(PHP_INT_MIN);
11-
} catch (\ValueError $e) {
12-
echo $e->getMessage() . PHP_EOL;
13-
}
14-
try {
15-
socket_strerror(PHP_INT_MAX);
11+
socket_strerror(2147483648);
1612
} catch (\ValueError $e) {
1713
echo $e->getMessage() . PHP_EOL;
1814
}
1915
?>
2016
--EXPECTF--
21-
socket_strerror(): Argument #1 ($error_code) must be between %s and %s
22-
socket_strerror(): Argument #1 ($error_code) must be between %s and %s
17+
string(%d) "%S"
18+
socket_strerror(): Argument #1 ($error_code) must be between %i and %d

0 commit comments

Comments
 (0)