Skip to content

Commit 931a8b0

Browse files
authored
inet_ntop requirement check at configure time instead (#12700)
1 parent 7f7da6a commit 931a8b0

File tree

11 files changed

+10
-48
lines changed

11 files changed

+10
-48
lines changed

Zend/Optimizer/zend_func_infos.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,7 @@ static const func_info_t func_infos[] = {
525525
F1("md5_file", MAY_BE_STRING|MAY_BE_FALSE),
526526
F1("sha1", MAY_BE_STRING),
527527
F1("sha1_file", MAY_BE_STRING|MAY_BE_FALSE),
528-
#if defined(HAVE_INET_NTOP)
529528
F1("inet_ntop", MAY_BE_STRING|MAY_BE_FALSE),
530-
#endif
531529
#if defined(HAVE_INET_PTON)
532530
F1("inet_pton", MAY_BE_STRING|MAY_BE_FALSE),
533531
#endif

configure.ac

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,6 @@ getgrnam_r \
609609
getpwuid_r \
610610
getwd \
611611
glob \
612-
inet_ntop \
613612
inet_pton \
614613
localtime_r \
615614
lchown \
@@ -646,6 +645,11 @@ memmem \
646645
memrchr \
647646
)
648647

648+
AC_CHECK_FUNCS(inet_ntop,[],[
649+
AC_MSG_ERROR([Cannot find inet_ntop which is required])
650+
]
651+
)
652+
649653
dnl Check for strerror_r, and if its a POSIX-compatible or a GNU specific version.
650654
AC_FUNC_STRERROR_R
651655

ext/ftp/ftp.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@
5656
#include <openssl/err.h>
5757
#endif
5858

59-
#ifndef HAVE_INET_NTOP
60-
#error inet_ntop unsupported on this platform
61-
#endif
62-
6359
#include "ftp.h"
6460
#include "ext/standard/fsock.h"
6561

@@ -1695,9 +1691,9 @@ ftp_getdata(ftpbuf_t *ftp)
16951691
char eprtarg[INET6_ADDRSTRLEN + sizeof("|x||xxxxx|")];
16961692
char out[INET6_ADDRSTRLEN];
16971693
int eprtarg_len;
1698-
if (!inet_ntop(AF_INET6, &((struct sockaddr_in6*) sa)->sin6_addr, out, sizeof(out))) {
1699-
goto bail;
1700-
}
1694+
const char *r;
1695+
r = inet_ntop(AF_INET6, &((struct sockaddr_in6*) sa)->sin6_addr, out, sizeof(out));
1696+
ZEND_ASSERT(r != NULL);
17011697

17021698
eprtarg_len = snprintf(eprtarg, sizeof(eprtarg), "|2|%s|%hu|", out, ntohs(((struct sockaddr_in6 *) &addr)->sin6_port));
17031699

ext/snmp/snmp.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@
5151
#endif
5252
#include <locale.h>
5353

54-
#ifndef HAVE_INET_NTOP
55-
#error inet_ntop unsupported on this platform
56-
#endif
57-
5854
#ifndef __P
5955
#ifdef __GNUC__
6056
#define __P(args) args

ext/sockets/sockets.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,6 @@ zend_module_entry sockets_module_entry = {
218218
ZEND_GET_MODULE(sockets)
219219
#endif
220220

221-
#ifndef HAVE_INET_NTOP
222-
#error inet_ntop unsupported on this platform
223-
#endif
224-
225221
static bool php_open_listen_sock(php_socket *sock, int port, int backlog) /* {{{ */
226222
{
227223
struct sockaddr_in la;

ext/standard/basic_functions.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,6 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
102102
# define INADDR_NONE ((zend_ulong) -1)
103103
#endif
104104

105-
#ifndef HAVE_INET_NTOP
106-
# error inet_ntop unsupported on this platform
107-
#endif
108-
109105
#include "zend_globals.h"
110106
#include "php_globals.h"
111107
#include "SAPI.h"
@@ -636,9 +632,7 @@ PHP_FUNCTION(long2ip)
636632
zend_ulong ip;
637633
zend_long sip;
638634
struct in_addr myaddr;
639-
#ifdef HAVE_INET_PTON
640635
char str[40];
641-
#endif
642636

643637
ZEND_PARSE_PARAMETERS_START(1, 1)
644638
Z_PARAM_LONG(sip)

ext/standard/basic_functions.stub.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,10 +2207,8 @@ function closelog(): true {}
22072207
function syslog(int $priority, string $message): true {} // TODO make return type void
22082208
#endif
22092209

2210-
#ifdef HAVE_INET_NTOP
22112210
/** @refcount 1 */
22122211
function inet_ntop(string $ip): string|false {}
2213-
#endif
22142212

22152213
#ifdef HAVE_INET_PTON
22162214
/** @refcount 1 */

ext/standard/basic_functions_arginfo.h

Lines changed: 2 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/standard/dns.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ extern void __res_ndestroy(res_state statp);
5757
#endif
5858
#endif
5959

60-
#ifndef HAVE_INET_NTOP
61-
#error inet_ntop unsupported on this platform
62-
#endif
63-
6460
#ifndef MAXHOSTNAMELEN
6561
#define MAXHOSTNAMELEN 255
6662
#endif

ext/standard/net.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@
4747
# include <netdb.h>
4848
#endif
4949

50-
#ifndef HAVE_INET_NTOP
51-
#error inet_ntop unsupported on this platform
52-
#endif
53-
5450
PHPAPI zend_string* php_inet_ntop(const struct sockaddr *addr) {
5551
socklen_t addrlen = sizeof(struct sockaddr_in);
5652

main/network.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@
6060
#endif
6161
#endif
6262

63-
#ifndef HAVE_INET_NTOP
64-
#error inet_ntop unsupported on this platform
65-
#endif
66-
6763
#ifndef HAVE_INET_ATON
6864
int inet_aton(const char *, struct in_addr *);
6965
#endif

0 commit comments

Comments
 (0)