Skip to content

Commit 9c4beac

Browse files
jorgsowapetk
authored andcommitted
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
1 parent 1feeadd commit 9c4beac

13 files changed

+6
-147
lines changed

UPGRADING.INTERNALS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ PHP 8.4 INTERNALS UPGRADE NOTES
3737
* The zend_*printf family of functions now supports the "%S" modifier to print
3838
out zend_string*. This won't cut off the string if it embeds a NUL byte.
3939

40+
* The inet_aton() and win32/inet.h on Windows have been removed. Use Windows
41+
native inet_pton() from ws2tcpip.h.
42+
4043
========================
4144
2. Build system changes
4245
========================
@@ -69,6 +72,7 @@ PHP 8.4 INTERNALS UPGRADE NOTES
6972
- Symbol ZEND_FIBER_ASM has been removed.
7073
- Symbols HAVE_DLOPEN and HAVE_DLSYM have been removed.
7174
- Symbol HAVE_LIBM has been removed.
75+
- Symbol HAVE_INET_ATON has been removed.
7276
- M4 macro PHP_DEFINE (atomic includes) removed (use AC_DEFINE and config.h).
7377
- M4 macro PHP_WITH_SHARED has been removed (use PHP_ARG_WITH).
7478
- M4 macro PHP_STRUCT_FLOCK has been removed (use AC_CHECK_TYPES).

configure.ac

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,6 @@ case $host_alias in
372372
;;
373373
esac
374374

375-
dnl Check for inet_aton in -lc and -lresolv.
376-
PHP_CHECK_FUNC(inet_aton, resolv)
377-
378375
dnl Then headers.
379376
dnl ----------------------------------------------------------------------------
380377

ext/sockets/sockets.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include "php_ini.h"
3131
#ifdef PHP_WIN32
3232
# include "windows_common.h"
33-
# include <win32/inet.h>
3433
# include <windows.h>
3534
# include <Ws2tcpip.h>
3635
# include "php_sockets.h"

ext/standard/basic_functions.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
6868

6969
#ifndef PHP_WIN32
7070
# include <netdb.h>
71-
#else
72-
#include "win32/inet.h"
7371
#endif
7472

7573
#ifdef HAVE_ARPA_INET_H

ext/standard/dns.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#endif
2626

2727
#ifdef PHP_WIN32
28-
# include "win32/inet.h"
2928
# include <winsock2.h>
3029
# include <windows.h>
3130
# include <Ws2tcpip.h>

ext/standard/flock_compat.c

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -149,69 +149,3 @@ PHPAPI int php_flock(int fd, int operation)
149149
return 0;
150150
}
151151
#endif
152-
153-
#ifndef PHP_WIN32
154-
#ifndef HAVE_INET_ATON
155-
/* {{{ inet_aton
156-
* Check whether "cp" is a valid ascii representation
157-
* of an Internet address and convert to a binary address.
158-
* Returns 1 if the address is valid, 0 if not.
159-
* This replaces inet_addr, the return value from which
160-
* cannot distinguish between failure and a local broadcast address.
161-
*/
162-
int inet_aton(const char *cp, struct in_addr *ap)
163-
{
164-
int dots = 0;
165-
unsigned long acc = 0, addr = 0;
166-
167-
do {
168-
char cc = *cp;
169-
170-
switch (cc) {
171-
case '0':
172-
case '1':
173-
case '2':
174-
case '3':
175-
case '4':
176-
case '5':
177-
case '6':
178-
case '7':
179-
case '8':
180-
case '9':
181-
acc = acc * 10 + (cc - '0');
182-
break;
183-
184-
case '.':
185-
if (++dots > 3) {
186-
return 0;
187-
}
188-
/* Fall through */
189-
190-
case '\0':
191-
if (acc > 255) {
192-
return 0;
193-
}
194-
addr = addr << 8 | acc;
195-
acc = 0;
196-
break;
197-
198-
default:
199-
return 0;
200-
}
201-
} while (*cp++) ;
202-
203-
/* Normalize the address */
204-
if (dots < 3) {
205-
addr <<= 8 * (3 - dots) ;
206-
}
207-
208-
/* Store it if requested */
209-
if (ap) {
210-
ap->s_addr = htonl(addr);
211-
}
212-
213-
return 1;
214-
}
215-
/* }}} */
216-
#endif /* !HAVE_INET_ATON */
217-
#endif

ext/standard/flock_compat.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,4 @@ PHPAPI int flock(int fd, int operation);
5757
# define ftruncate(a, b) chsize(a, b)
5858
#endif /* defined(PHP_WIN32) */
5959

60-
#ifndef HAVE_INET_ATON
61-
# ifdef HAVE_NETINET_IN_H
62-
# include <netinet/in.h>
63-
# endif
64-
# ifdef HAVE_ARPA_INET_H
65-
# include <arpa/inet.h>
66-
# endif
67-
# ifndef PHP_WIN32
68-
extern int inet_aton(const char *, struct in_addr *);
69-
# endif
70-
#endif
71-
7260
#endif /* FLOCK_COMPAT_H */

main/network.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
#ifdef PHP_WIN32
2727
# include <Ws2tcpip.h>
28-
# include "win32/inet.h"
2928
# include "win32/winutil.h"
3029
# define O_RDONLY _O_RDONLY
3130
# include "win32/param.h"
@@ -60,10 +59,6 @@
6059
#endif
6160
#endif
6261

63-
#ifndef HAVE_INET_ATON
64-
int inet_aton(const char *, struct in_addr *);
65-
#endif
66-
6762
#include "php_network.h"
6863

6964
#if defined(PHP_WIN32) || defined(__riscos__)

main/php_network.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919

2020
#include <php.h>
2121

22-
#ifdef PHP_WIN32
23-
# include "win32/inet.h"
24-
#else
22+
#ifndef PHP_WIN32
2523
# undef closesocket
2624
# define closesocket close
2725
# include <netinet/tcp.h>

win32/build/config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ if (VS_TOOLSET && VCVERS >= 1914) {
307307
ADD_SOURCES("win32", "dllmain.c glob.c readdir.c \
308308
registry.c select.c sendmail.c time.c winutil.c wsyslog.c globals.c \
309309
getrusage.c ftok.c ioutil.c codepage.c nice.c \
310-
inet.c fnmatch.c sockets.c console.c signal.c");
310+
fnmatch.c sockets.c console.c signal.c");
311311

312312
ADD_FLAG("CFLAGS_BD_WIN32", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
313313
if (VS_TOOLSET && VCVERS >= 1914) {

win32/inet.c

Lines changed: 0 additions & 27 deletions
This file was deleted.

win32/inet.h

Lines changed: 0 additions & 25 deletions
This file was deleted.

win32/sendmail.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include <winbase.h>
3030
#include "sendmail.h"
3131
#include "php_ini.h"
32-
#include "inet.h"
3332

3433
#include "php_win32_globals.h"
3534

0 commit comments

Comments
 (0)