Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Zend/Optimizer/zend_func_infos.h
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ static const func_info_t func_infos[] = {
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),
F1("base64_encode", MAY_BE_STRING),
F1("base64_decode", MAY_BE_STRING|MAY_BE_FALSE),
F1("long2ip", MAY_BE_STRING|MAY_BE_FALSE),
F1("long2ip", MAY_BE_STRING),
F1("getenv", MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE),
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),
#if defined(HAVE_NANOSLEEP)
Expand Down
8 changes: 3 additions & 5 deletions ext/standard/basic_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,11 +643,9 @@ PHP_FUNCTION(long2ip)
ip = (zend_ulong)sip;

myaddr.s_addr = htonl(ip);
if (inet_ntop(AF_INET, &myaddr, str, sizeof(str))) {
RETURN_STRING(str);
} else {
RETURN_FALSE;
}
inet_ntop(AF_INET, &myaddr, str, sizeof(str));

RETURN_STRING(str);
}
/* }}} */

Expand Down
2 changes: 1 addition & 1 deletion ext/standard/basic_functions.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -1945,7 +1945,7 @@ function constant(string $name): mixed {}
function ip2long(string $ip): int|false {}

/** @refcount 1 */
function long2ip(int $ip): string|false {}
function long2ip(int $ip): string {}

/**
* @return string|array<string, string>|false
Expand Down
4 changes: 2 additions & 2 deletions ext/standard/basic_functions_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions ext/standard/tests/network/ip_x86_64.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var_dump(ip2long("777.777.777.777"));
var_dump(ip2long("111.111.111.111"));

var_dump(long2ip(-110000));
var_dump(long2ip(PHP_INT_MAX));
var_dump(long2ip(PHP_INT_MIN));

echo "Done\n";
?>
Expand All @@ -46,4 +48,6 @@ bool(false)
bool(false)
int(1869573999)
string(13) "255.254.82.80"
string(15) "255.255.255.255"
string(7) "0.0.0.0"
Done