Remove inet_aton

This removes the deprecated inet_aton and its Windows implementation.
The inet_aton can be replaced with platform agnostic inet_pton.

Closes GH-13479
This commit is contained in:
Jorg Sowa 2024-02-23 23:11:47 +01:00 committed by Peter Kokot
parent 1feeadd0e2
commit 9c4beac8d3
13 changed files with 6 additions and 147 deletions

View file

@ -37,6 +37,9 @@ PHP 8.4 INTERNALS UPGRADE NOTES
* The zend_*printf family of functions now supports the "%S" modifier to print
out zend_string*. This won't cut off the string if it embeds a NUL byte.
* The inet_aton() and win32/inet.h on Windows have been removed. Use Windows
native inet_pton() from ws2tcpip.h.
========================
2. Build system changes
========================
@ -69,6 +72,7 @@ PHP 8.4 INTERNALS UPGRADE NOTES
- Symbol ZEND_FIBER_ASM has been removed.
- Symbols HAVE_DLOPEN and HAVE_DLSYM have been removed.
- Symbol HAVE_LIBM has been removed.
- Symbol HAVE_INET_ATON has been removed.
- M4 macro PHP_DEFINE (atomic includes) removed (use AC_DEFINE and config.h).
- M4 macro PHP_WITH_SHARED has been removed (use PHP_ARG_WITH).
- M4 macro PHP_STRUCT_FLOCK has been removed (use AC_CHECK_TYPES).

View file

@ -372,9 +372,6 @@ case $host_alias in
;;
esac
dnl Check for inet_aton in -lc and -lresolv.
PHP_CHECK_FUNC(inet_aton, resolv)
dnl Then headers.
dnl ----------------------------------------------------------------------------

View file

@ -30,7 +30,6 @@
#include "php_ini.h"
#ifdef PHP_WIN32
# include "windows_common.h"
# include <win32/inet.h>
# include <windows.h>
# include <Ws2tcpip.h>
# include "php_sockets.h"

View file

@ -68,8 +68,6 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
#ifndef PHP_WIN32
# include <netdb.h>
#else
#include "win32/inet.h"
#endif
#ifdef HAVE_ARPA_INET_H

View file

@ -25,7 +25,6 @@
#endif
#ifdef PHP_WIN32
# include "win32/inet.h"
# include <winsock2.h>
# include <windows.h>
# include <Ws2tcpip.h>

View file

@ -149,69 +149,3 @@ PHPAPI int php_flock(int fd, int operation)
return 0;
}
#endif
#ifndef PHP_WIN32
#ifndef HAVE_INET_ATON
/* {{{ inet_aton
* Check whether "cp" is a valid ascii representation
* of an Internet address and convert to a binary address.
* Returns 1 if the address is valid, 0 if not.
* This replaces inet_addr, the return value from which
* cannot distinguish between failure and a local broadcast address.
*/
int inet_aton(const char *cp, struct in_addr *ap)
{
int dots = 0;
unsigned long acc = 0, addr = 0;
do {
char cc = *cp;
switch (cc) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
acc = acc * 10 + (cc - '0');
break;
case '.':
if (++dots > 3) {
return 0;
}
/* Fall through */
case '\0':
if (acc > 255) {
return 0;
}
addr = addr << 8 | acc;
acc = 0;
break;
default:
return 0;
}
} while (*cp++) ;
/* Normalize the address */
if (dots < 3) {
addr <<= 8 * (3 - dots) ;
}
/* Store it if requested */
if (ap) {
ap->s_addr = htonl(addr);
}
return 1;
}
/* }}} */
#endif /* !HAVE_INET_ATON */
#endif

View file

@ -57,16 +57,4 @@ PHPAPI int flock(int fd, int operation);
# define ftruncate(a, b) chsize(a, b)
#endif /* defined(PHP_WIN32) */
#ifndef HAVE_INET_ATON
# ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
# endif
# ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
# endif
# ifndef PHP_WIN32
extern int inet_aton(const char *, struct in_addr *);
# endif
#endif
#endif /* FLOCK_COMPAT_H */

View file

@ -25,7 +25,6 @@
#ifdef PHP_WIN32
# include <Ws2tcpip.h>
# include "win32/inet.h"
# include "win32/winutil.h"
# define O_RDONLY _O_RDONLY
# include "win32/param.h"
@ -60,10 +59,6 @@
#endif
#endif
#ifndef HAVE_INET_ATON
int inet_aton(const char *, struct in_addr *);
#endif
#include "php_network.h"
#if defined(PHP_WIN32) || defined(__riscos__)

View file

@ -19,9 +19,7 @@
#include <php.h>
#ifdef PHP_WIN32
# include "win32/inet.h"
#else
#ifndef PHP_WIN32
# undef closesocket
# define closesocket close
# include <netinet/tcp.h>

View file

@ -307,7 +307,7 @@ if (VS_TOOLSET && VCVERS >= 1914) {
ADD_SOURCES("win32", "dllmain.c glob.c readdir.c \
registry.c select.c sendmail.c time.c winutil.c wsyslog.c globals.c \
getrusage.c ftok.c ioutil.c codepage.c nice.c \
inet.c fnmatch.c sockets.c console.c signal.c");
fnmatch.c sockets.c console.c signal.c");
ADD_FLAG("CFLAGS_BD_WIN32", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
if (VS_TOOLSET && VCVERS >= 1914) {

View file

@ -1,27 +0,0 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Pierre Joye <pierre@php.net> |
+----------------------------------------------------------------------+
*/
#include "inet.h"
int inet_aton(const char *cp, struct in_addr *inp) {
inp->s_addr = inet_addr(cp);
if (inp->s_addr == INADDR_NONE) {
return 0;
}
return 1;
}

View file

@ -1,25 +0,0 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Pierre Joye <pierre@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_WIN32_INET_H
#define PHP_WIN32_INET_H
#include <php.h>
#include <Winsock2.h>
PHPAPI int inet_aton(const char *cp, struct in_addr *inp);
#endif

View file

@ -29,7 +29,6 @@
#include <winbase.h>
#include "sendmail.h"
#include "php_ini.h"
#include "inet.h"
#include "php_win32_globals.h"