diff --git a/Zend/Optimizer/zend_func_infos.h b/Zend/Optimizer/zend_func_infos.h index 16971fc178ea7..7e7415b829d8c 100644 --- a/Zend/Optimizer/zend_func_infos.h +++ b/Zend/Optimizer/zend_func_infos.h @@ -517,9 +517,7 @@ static const func_info_t func_infos[] = { F1("sha1", MAY_BE_STRING), F1("sha1_file", MAY_BE_STRING|MAY_BE_FALSE), F1("inet_ntop", MAY_BE_STRING|MAY_BE_FALSE), -#if defined(HAVE_INET_PTON) F1("inet_pton", MAY_BE_STRING|MAY_BE_FALSE), -#endif F1("metaphone", MAY_BE_STRING), F1("headers_list", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING), F1("htmlspecialchars", MAY_BE_STRING), diff --git a/configure.ac b/configure.ac index 70334bf55ee06..6f96b88be4021 100644 --- a/configure.ac +++ b/configure.ac @@ -602,7 +602,6 @@ getgrnam_r \ getpwuid_r \ getwd \ glob \ -inet_pton \ localtime_r \ lchown \ memcntl \ @@ -644,6 +643,11 @@ AC_CHECK_FUNC(inet_ntop,[],[ ] ) +AC_CHECK_FUNC(inet_pton,[],[ + AC_MSG_ERROR([Cannot find inet_pton which is required]) +] +) + dnl Check for strerror_r, and if its a POSIX-compatible or a GNU specific version. AC_FUNC_STRERROR_R diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c index 38acea244a217..2a8b7c6111887 100644 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@ -130,7 +130,7 @@ #define PHP_X509_NAME_ENTRY_TO_UTF8(ne, i, out) \ ASN1_STRING_to_UTF8(&out, X509_NAME_ENTRY_get_data(X509_NAME_get_entry(ne, i))) -#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON) +#if defined(HAVE_IPV6) /* Used for IPv6 Address peer verification */ #define EXPAND_IPV6_ADDRESS(_str, _bytes) \ do { \ diff --git a/ext/sockets/sockaddr_conv.c b/ext/sockets/sockaddr_conv.c index e4a7347cafab3..133bdbb2813d3 100644 --- a/ext/sockets/sockaddr_conv.c +++ b/ext/sockets/sockaddr_conv.c @@ -89,11 +89,7 @@ int php_set_inet_addr(struct sockaddr_in *sin, char *string, php_socket *php_soc struct in_addr tmp; struct hostent *host_entry; -#ifdef HAVE_INET_PTON if (inet_pton(AF_INET, string, &tmp)) { -#else - if (inet_aton(string, &tmp)) { -#endif sin->sin_addr.s_addr = tmp.s_addr; } else { if (strlen(string) > MAXFQDNLEN || ! (host_entry = php_network_gethostbyname(string))) { diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index d62951b63ff26..3ae5fa2afafcf 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -555,7 +555,6 @@ PHP_FUNCTION(inet_ntop) } /* }}} */ -#ifdef HAVE_INET_PTON /* {{{ Converts a human readable IP address to a packed binary string */ PHP_FUNCTION(inet_pton) { @@ -588,42 +587,22 @@ PHP_FUNCTION(inet_pton) RETURN_STRINGL(buffer, af == AF_INET ? 4 : 16); } /* }}} */ -#endif /* HAVE_INET_PTON */ /* {{{ Converts a string containing an (IPv4) Internet Protocol dotted address into a proper address */ PHP_FUNCTION(ip2long) { char *addr; size_t addr_len; -#ifdef HAVE_INET_PTON struct in_addr ip; -#else - zend_ulong ip; -#endif ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STRING(addr, addr_len) ZEND_PARSE_PARAMETERS_END(); -#ifdef HAVE_INET_PTON if (addr_len == 0 || inet_pton(AF_INET, addr, &ip) != 1) { RETURN_FALSE; } RETURN_LONG(ntohl(ip.s_addr)); -#else - if (addr_len == 0 || (ip = inet_addr(addr)) == INADDR_NONE) { - /* The only special case when we should return -1 ourselves, - * because inet_addr() considers it wrong. We return 0xFFFFFFFF and - * not -1 or ~0 because of 32/64bit issues. */ - if (addr_len == sizeof("255.255.255.255") - 1 && - !memcmp(addr, "255.255.255.255", sizeof("255.255.255.255") - 1) - ) { - RETURN_LONG(0xFFFFFFFF); - } - RETURN_FALSE; - } - RETURN_LONG(ntohl(ip)); -#endif } /* }}} */ diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index ed73d16d6d0b9..1c8d8d2537871 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -2238,10 +2238,8 @@ function syslog(int $priority, string $message): true {} // TODO make return typ /** @refcount 1 */ function inet_ntop(string $ip): string|false {} -#ifdef HAVE_INET_PTON /** @refcount 1 */ function inet_pton(string $ip): string|false {} -#endif /* metaphone.c */ diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index 4efdcb54546b6..1a4f3f5f965ef 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: 8f5af1b9f31974b817496ca514374167cf798703 */ 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) @@ -722,11 +722,7 @@ ZEND_END_ARG_INFO() #define arginfo_inet_ntop arginfo_gethostbyaddr -#if defined(HAVE_INET_PTON) -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_inet_pton, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, ip, IS_STRING, 0) -ZEND_END_ARG_INFO() -#endif +#define arginfo_inet_pton arginfo_gethostbyaddr ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_metaphone, 0, 1, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) @@ -2522,9 +2518,7 @@ ZEND_FUNCTION(closelog); ZEND_FUNCTION(syslog); #endif ZEND_FUNCTION(inet_ntop); -#if defined(HAVE_INET_PTON) ZEND_FUNCTION(inet_pton); -#endif ZEND_FUNCTION(metaphone); ZEND_FUNCTION(header); ZEND_FUNCTION(header_remove); @@ -3156,9 +3150,7 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(syslog, arginfo_syslog) #endif ZEND_FE(inet_ntop, arginfo_inet_ntop) -#if defined(HAVE_INET_PTON) ZEND_FE(inet_pton, arginfo_inet_pton) -#endif ZEND_FE(metaphone, arginfo_metaphone) ZEND_FE(header, arginfo_header) ZEND_FE(header_remove, arginfo_header_remove) diff --git a/ext/standard/dns.c b/ext/standard/dns.c index d8f4f6aa3b550..7296aafc47ab2 100644 --- a/ext/standard/dns.c +++ b/ext/standard/dns.c @@ -157,7 +157,7 @@ PHP_FUNCTION(gethostbyaddr) hostname = php_gethostbyaddr(addr); if (hostname == NULL) { -#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON) +#if defined(HAVE_IPV6) php_error_docref(NULL, E_WARNING, "Address is not a valid IPv4 or IPv6 address"); #else php_error_docref(NULL, E_WARNING, "Address is not in a.b.c.d form"); @@ -172,7 +172,7 @@ PHP_FUNCTION(gethostbyaddr) /* {{{ php_gethostbyaddr */ static zend_string *php_gethostbyaddr(char *ip) { -#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON) +#if defined(HAVE_IPV6) struct sockaddr_in sa4; struct sockaddr_in6 sa6; char out[NI_MAXHOST]; diff --git a/ext/standard/tests/network/ip2long_variation2.phpt b/ext/standard/tests/network/ip2long_variation2.phpt index bbcd4ea876cfa..e517bbe865ba1 100644 --- a/ext/standard/tests/network/ip2long_variation2.phpt +++ b/ext/standard/tests/network/ip2long_variation2.phpt @@ -1,8 +1,10 @@ --TEST-- Test ip2long() function : usage variation 2, 32 bit --SKIPIF-- - - + --FILE-- MAXFQDNLEN) { diff --git a/main/network.c b/main/network.c index 2aca0002887dd..f3c85fb1bdd15 100644 --- a/main/network.c +++ b/main/network.c @@ -237,11 +237,7 @@ PHPAPI int php_network_getaddresses(const char *host, int socktype, struct socka freeaddrinfo(res); #else -#ifdef HAVE_INET_PTON if (!inet_pton(AF_INET, host, &in)) { -#else - if (!inet_aton(host, &in)) { -#endif if(strlen(host) > MAXFQDNLEN) { host_info = NULL; errno = E2BIG; @@ -545,7 +541,7 @@ PHPAPI int php_network_parse_network_address_with_port(const char *addr, zend_lo /* first, try interpreting the address as a numeric address */ -#if HAVE_IPV6 && HAVE_INET_PTON +#if HAVE_IPV6 if (inet_pton(AF_INET6, tmp, &in6->sin6_addr) > 0) { in6->sin6_port = htons(port); in6->sin6_family = AF_INET6; @@ -554,11 +550,7 @@ PHPAPI int php_network_parse_network_address_with_port(const char *addr, zend_lo goto out; } #endif -#ifdef HAVE_INET_PTON if (inet_pton(AF_INET, tmp, &in4->sin_addr) > 0) { -#else - if (inet_aton(tmp, &in4->sin_addr) > 0) { -#endif in4->sin_port = htons(port); in4->sin_family = AF_INET; *sl = sizeof(struct sockaddr_in); @@ -852,25 +844,21 @@ php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short union { struct sockaddr common; struct sockaddr_in in4; -#if HAVE_IPV6 && HAVE_INET_PTON +#if HAVE_IPV6 struct sockaddr_in6 in6; #endif } local_address; int local_address_len = 0; if (sa->sa_family == AF_INET) { -#ifdef HAVE_INET_PTON if (inet_pton(AF_INET, bindto, &local_address.in4.sin_addr) == 1) { -#else - if (inet_aton(bindto, &local_address.in4.sin_addr)) { -#endif local_address_len = sizeof(struct sockaddr_in); local_address.in4.sin_family = sa->sa_family; local_address.in4.sin_port = htons(bindport); memset(&(local_address.in4.sin_zero), 0, sizeof(local_address.in4.sin_zero)); } } -#if HAVE_IPV6 && HAVE_INET_PTON +#if HAVE_IPV6 else { /* IPV6 */ if (inet_pton(AF_INET6, bindto, &local_address.in6.sin6_addr) == 1) { local_address_len = sizeof(struct sockaddr_in6); diff --git a/sapi/litespeed/lsapilib.c b/sapi/litespeed/lsapilib.c index ca47039a636a9..ce97f0bbe9dc7 100644 --- a/sapi/litespeed/lsapilib.c +++ b/sapi/litespeed/lsapilib.c @@ -2688,12 +2688,7 @@ int LSAPI_ParseSockAddr( const char * pBind, struct sockaddr * pAddr ) ((struct sockaddr_in *)pAddr)->sin_addr.s_addr = htonl( INADDR_LOOPBACK ); else { -#ifdef HAVE_INET_PTON if (!inet_pton(AF_INET, p, &((struct sockaddr_in *)pAddr)->sin_addr)) -#else - ((struct sockaddr_in *)pAddr)->sin_addr.s_addr = inet_addr( p ); - if ( ((struct sockaddr_in *)pAddr)->sin_addr.s_addr == INADDR_BROADCAST) -#endif { doAddrInfo = 1; } diff --git a/win32/build/config.w32.h.in b/win32/build/config.w32.h.in index 3eb161149716a..166817a673bce 100644 --- a/win32/build/config.w32.h.in +++ b/win32/build/config.w32.h.in @@ -116,9 +116,6 @@ /* Win32 support proc_open */ #define PHP_CAN_SUPPORT_PROC_OPEN 1 -/* inet_pton() */ -#define HAVE_INET_PTON 1 - /* vs.net 2005 has a 64-bit time_t. This will likely break * 3rdParty libs that were built with older compilers; switch * back to 32-bit */