Skip to content

Commit e7b1f2a

Browse files
authored
Change long2ip return type (#13395)
1 parent eaaffae commit e7b1f2a

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

Zend/Optimizer/zend_func_infos.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ static const func_info_t func_infos[] = {
468468
FN("array_rand", MAY_BE_LONG|MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING),
469469
F1("base64_encode", MAY_BE_STRING),
470470
F1("base64_decode", MAY_BE_STRING|MAY_BE_FALSE),
471-
F1("long2ip", MAY_BE_STRING|MAY_BE_FALSE),
471+
F1("long2ip", MAY_BE_STRING),
472472
F1("getenv", MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
473473
F1("getopt", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_ARRAY_OF_FALSE|MAY_BE_FALSE),
474474
#if defined(HAVE_NANOSLEEP)

ext/standard/basic_functions.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -643,11 +643,10 @@ PHP_FUNCTION(long2ip)
643643
ip = (zend_ulong)sip;
644644

645645
myaddr.s_addr = htonl(ip);
646-
if (inet_ntop(AF_INET, &myaddr, str, sizeof(str))) {
647-
RETURN_STRING(str);
648-
} else {
649-
RETURN_FALSE;
650-
}
646+
const char* result = inet_ntop(AF_INET, &myaddr, str, sizeof(str));
647+
ZEND_ASSERT(result != NULL);
648+
649+
RETURN_STRING(str);
651650
}
652651
/* }}} */
653652

ext/standard/basic_functions.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1945,7 +1945,7 @@ function constant(string $name): mixed {}
19451945
function ip2long(string $ip): int|false {}
19461946

19471947
/** @refcount 1 */
1948-
function long2ip(int $ip): string|false {}
1948+
function long2ip(int $ip): string {}
19491949

19501950
/**
19511951
* @return string|array<string, string>|false

ext/standard/basic_functions_arginfo.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/standard/tests/network/ip_x86_64.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ var_dump(ip2long("777.777.777.777"));
2626
var_dump(ip2long("111.111.111.111"));
2727

2828
var_dump(long2ip(-110000));
29+
var_dump(long2ip(PHP_INT_MAX));
30+
var_dump(long2ip(PHP_INT_MIN));
2931

3032
echo "Done\n";
3133
?>
@@ -46,4 +48,6 @@ bool(false)
4648
bool(false)
4749
int(1869573999)
4850
string(13) "255.254.82.80"
51+
string(15) "255.255.255.255"
52+
string(7) "0.0.0.0"
4953
Done

0 commit comments

Comments
 (0)