diff --git a/Zend/Optimizer/zend_func_infos.h b/Zend/Optimizer/zend_func_infos.h index 16971fc178ea7..d1799ad0de821 100644 --- a/Zend/Optimizer/zend_func_infos.h +++ b/Zend/Optimizer/zend_func_infos.h @@ -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) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index d62951b63ff26..ed4309818275a 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -643,11 +643,10 @@ 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; - } + const char* result = inet_ntop(AF_INET, &myaddr, str, sizeof(str)); + ZEND_ASSERT(result != NULL); + + RETURN_STRING(str); } /* }}} */ diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index ed73d16d6d0b9..899d29ea3b078 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -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|false diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index 4efdcb54546b6..7a1812d7ca565 100644 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 0bd0ac5d23881670cac81cda3e274cbee1e9a8dc */ + * Stub hash: 1350cc5169dbd48df08513f01c10d5706d47b8d4 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0) @@ -381,7 +381,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ip2long, 0, 1, MAY_BE_LONG|MAY_B ZEND_ARG_TYPE_INFO(0, ip, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_long2ip, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_long2ip, 0, 1, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, ip, IS_LONG, 0) ZEND_END_ARG_INFO() diff --git a/ext/standard/tests/network/ip_x86_64.phpt b/ext/standard/tests/network/ip_x86_64.phpt index dd81bde55c89b..16e855188aafa 100644 --- a/ext/standard/tests/network/ip_x86_64.phpt +++ b/ext/standard/tests/network/ip_x86_64.phpt @@ -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"; ?> @@ -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