Skip to content

inet_ntop requirement check at configure time instead #12700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Zend/Optimizer/zend_func_infos.h
Original file line number Diff line number Diff line change
Expand Up @@ -525,9 +525,7 @@ static const func_info_t func_infos[] = {
F1("md5_file", MAY_BE_STRING|MAY_BE_FALSE),
F1("sha1", MAY_BE_STRING),
F1("sha1_file", MAY_BE_STRING|MAY_BE_FALSE),
#if defined(HAVE_INET_NTOP)
F1("inet_ntop", MAY_BE_STRING|MAY_BE_FALSE),
#endif
#if defined(HAVE_INET_PTON)
F1("inet_pton", MAY_BE_STRING|MAY_BE_FALSE),
#endif
Expand Down
6 changes: 5 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,6 @@ getgrnam_r \
getpwuid_r \
getwd \
glob \
inet_ntop \
inet_pton \
localtime_r \
lchown \
Expand Down Expand Up @@ -646,6 +645,11 @@ memmem \
memrchr \
)

AC_CHECK_FUNCS(inet_ntop,[],[
AC_MSG_ERROR([Cannot find inet_ntop which is required])
]
)

dnl Check for strerror_r, and if its a POSIX-compatible or a GNU specific version.
AC_FUNC_STRERROR_R

Expand Down
10 changes: 3 additions & 7 deletions ext/ftp/ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@
#include <openssl/err.h>
#endif

#ifndef HAVE_INET_NTOP
#error inet_ntop unsupported on this platform
#endif

#include "ftp.h"
#include "ext/standard/fsock.h"

Expand Down Expand Up @@ -1695,9 +1691,9 @@ ftp_getdata(ftpbuf_t *ftp)
char eprtarg[INET6_ADDRSTRLEN + sizeof("|x||xxxxx|")];
char out[INET6_ADDRSTRLEN];
int eprtarg_len;
if (!inet_ntop(AF_INET6, &((struct sockaddr_in6*) sa)->sin6_addr, out, sizeof(out))) {
goto bail;
}
const char *r;
r = inet_ntop(AF_INET6, &((struct sockaddr_in6*) sa)->sin6_addr, out, sizeof(out));
ZEND_ASSERT(r != NULL);

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

Expand Down
4 changes: 0 additions & 4 deletions ext/snmp/snmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@
#endif
#include <locale.h>

#ifndef HAVE_INET_NTOP
#error inet_ntop unsupported on this platform
#endif

#ifndef __P
#ifdef __GNUC__
#define __P(args) args
Expand Down
4 changes: 0 additions & 4 deletions ext/sockets/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,6 @@ zend_module_entry sockets_module_entry = {
ZEND_GET_MODULE(sockets)
#endif

#ifndef HAVE_INET_NTOP
#error inet_ntop unsupported on this platform
#endif

static bool php_open_listen_sock(php_socket *sock, int port, int backlog) /* {{{ */
{
struct sockaddr_in la;
Expand Down
6 changes: 0 additions & 6 deletions ext/standard/basic_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
# define INADDR_NONE ((zend_ulong) -1)
#endif

#ifndef HAVE_INET_NTOP
# error inet_ntop unsupported on this platform
#endif

#include "zend_globals.h"
#include "php_globals.h"
#include "SAPI.h"
Expand Down Expand Up @@ -636,9 +632,7 @@ PHP_FUNCTION(long2ip)
zend_ulong ip;
zend_long sip;
struct in_addr myaddr;
#ifdef HAVE_INET_PTON
char str[40];
#endif

ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_LONG(sip)
Expand Down
2 changes: 0 additions & 2 deletions ext/standard/basic_functions.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2207,10 +2207,8 @@ function closelog(): true {}
function syslog(int $priority, string $message): true {} // TODO make return type void
#endif

#ifdef HAVE_INET_NTOP
/** @refcount 1 */
function inet_ntop(string $ip): string|false {}
#endif

#ifdef HAVE_INET_PTON
/** @refcount 1 */
Expand Down
12 changes: 2 additions & 10 deletions ext/standard/basic_functions_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions ext/standard/dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ extern void __res_ndestroy(res_state statp);
#endif
#endif

#ifndef HAVE_INET_NTOP
#error inet_ntop unsupported on this platform
#endif

#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 255
#endif
Expand Down
4 changes: 0 additions & 4 deletions ext/standard/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@
# include <netdb.h>
#endif

#ifndef HAVE_INET_NTOP
#error inet_ntop unsupported on this platform
#endif

PHPAPI zend_string* php_inet_ntop(const struct sockaddr *addr) {
socklen_t addrlen = sizeof(struct sockaddr_in);

Expand Down
4 changes: 0 additions & 4 deletions main/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@
#endif
#endif

#ifndef HAVE_INET_NTOP
#error inet_ntop unsupported on this platform
#endif

#ifndef HAVE_INET_ATON
int inet_aton(const char *, struct in_addr *);
#endif
Expand Down