public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/php] private-php86: get rid of inet_addr and gethostbyaddr calls
@ 2026-11-27  7:31 Remi Collet
  0 siblings, 0 replies; only message in thread
From: Remi Collet @ 2026-11-27  7:31 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/php
Branch : private-php86
Commit : 2201155ebf94a218d4175054d012abb7d944d12f
Author : Remi Collet <remi@fedoraproject.org>
Date   : 2021-05-08T15:07:01+02:00
Stats  : +118/-1 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/php/c/2201155ebf94a218d4175054d012abb7d944d12f?branch=private-php86

Log:
get rid of inet_addr and gethostbyaddr calls

---
diff --git a/php-8.0.6-deprecated.patch b/php-8.0.6-deprecated.patch
index d90d0fa..1e6b93b 100644
--- a/php-8.0.6-deprecated.patch
+++ b/php-8.0.6-deprecated.patch
@@ -284,3 +284,117 @@ index 2c504952b2dd1..7f2f714ec42df 100644
  						php_error_docref(NULL, E_WARNING, "Invalid IP Address: %s", bindto);
  						goto skip_bind;
  					}
+From e5b6f43ec7813392d83ea586b7902e0396a1f792 Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@remirepo.net>
+Date: Thu, 6 May 2021 14:21:29 +0200
+Subject: [PATCH] get rid of inet_addr usage
+
+---
+ main/fastcgi.c            | 4 ++++
+ sapi/litespeed/lsapilib.c | 4 ++++
+ 2 files changed, 8 insertions(+)
+
+diff --git a/main/fastcgi.c b/main/fastcgi.c
+index 071f69d3a7f0..c936d42405de 100644
+--- a/main/fastcgi.c
++++ b/main/fastcgi.c
+@@ -688,8 +688,12 @@ int fcgi_listen(const char *path, int backlog)
+ 		if (!*host || !strncmp(host, "*", sizeof("*")-1)) {
+ 			sa.sa_inet.sin_addr.s_addr = htonl(INADDR_ANY);
+ 		} else {
++#ifdef HAVE_INET_PTON
++			if (!inet_pton(AF_INET, host, &sa.sa_inet.sin_addr)) {
++#else
+ 			sa.sa_inet.sin_addr.s_addr = inet_addr(host);
+ 			if (sa.sa_inet.sin_addr.s_addr == INADDR_NONE) {
++#endif
+ 				struct hostent *hep;
+ 
+ 				if(strlen(host) > MAXFQDNLEN) {
+diff --git a/sapi/litespeed/lsapilib.c b/sapi/litespeed/lsapilib.c
+index a72b5dc1b988..305f3326a682 100644
+--- a/sapi/litespeed/lsapilib.c
++++ b/sapi/litespeed/lsapilib.c
+@@ -2672,8 +2672,12 @@ 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;
+             }
+From 99d67d121acd4c324738509679d23acaf759d065 Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@remirepo.net>
+Date: Thu, 6 May 2021 16:35:48 +0200
+Subject: [PATCH] use getnameinfo instead of gethostbyaddr
+
+---
+ ext/standard/dns.c | 34 ++++++++++++++++++++++------------
+ 1 file changed, 22 insertions(+), 12 deletions(-)
+
+diff --git a/ext/standard/dns.c b/ext/standard/dns.c
+index edd9a4549f5c..540c777faaba 100644
+--- a/ext/standard/dns.c
++++ b/ext/standard/dns.c
+@@ -169,20 +169,30 @@ PHP_FUNCTION(gethostbyaddr)
+ static zend_string *php_gethostbyaddr(char *ip)
+ {
+ #if HAVE_IPV6 && HAVE_INET_PTON
+-	struct in6_addr addr6;
+-#endif
+-	struct in_addr addr;
+-	struct hostent *hp;
++	struct sockaddr_in sa4;
++	struct sockaddr_in6 sa6;
++	char out[NI_MAXHOST];
+ 
+-#if HAVE_IPV6 && HAVE_INET_PTON
+-	if (inet_pton(AF_INET6, ip, &addr6)) {
+-		hp = gethostbyaddr((char *) &addr6, sizeof(addr6), AF_INET6);
+-	} else if (inet_pton(AF_INET, ip, &addr)) {
+-		hp = gethostbyaddr((char *) &addr, sizeof(addr), AF_INET);
+-	} else {
+-		return NULL;
++	if (inet_pton(AF_INET6, ip, &sa6.sin6_addr)) {
++		sa6.sin6_family = AF_INET6;
++
++		if (getnameinfo((struct sockaddr *)&sa6, sizeof(sa6), out, sizeof(out), NULL, 0, NI_NAMEREQD) < 0) {
++			return zend_string_init(ip, strlen(ip), 0);
++		}
++		return zend_string_init(out, strlen(out), 0);
++	} else if (inet_pton(AF_INET, ip, &sa4.sin_addr)) {
++		sa4.sin_family = AF_INET;
++
++		if (getnameinfo((struct sockaddr *)&sa4, sizeof(sa4), out, sizeof(out), NULL, 0, NI_NAMEREQD) < 0) {
++			return zend_string_init(ip, strlen(ip), 0);
++		}
++		return zend_string_init(out, strlen(out), 0);
+ 	}
++	return NULL; /* not a valid IP */
+ #else
++	struct in_addr addr;
++	struct hostent *hp;
++
+ 	addr.s_addr = inet_addr(ip);
+ 
+ 	if (addr.s_addr == -1) {
+@@ -190,13 +200,13 @@ static zend_string *php_gethostbyaddr(char *ip)
+ 	}
+ 
+ 	hp = gethostbyaddr((char *) &addr, sizeof(addr), AF_INET);
+-#endif
+ 
+ 	if (!hp || hp->h_name == NULL || hp->h_name[0] == '\0') {
+ 		return zend_string_init(ip, strlen(ip), 0);
+ 	}
+ 
+ 	return zend_string_init(hp->h_name, strlen(hp->h_name), 0);
++#endif
+ }
+ /* }}} */
+ 

diff --git a/php.spec b/php.spec
index cc15e46..e1f696f 100644
--- a/php.spec
+++ b/php.spec
@@ -62,7 +62,7 @@
 Summary: PHP scripting language for creating dynamic web sites
 Name: php
 Version: %{upver}%{?rcver:~%{rcver}}
-Release: 2%{?dist}
+Release: 3%{?dist}
 # All files licensed under PHP version 3.01, except
 # Zend is licensed under Zend
 # TSRM is licensed under BSD
@@ -1521,6 +1521,9 @@ systemctl try-restart php-fpm.service >/dev/null 2>&1 || :
 
 
 %changelog
+* Sat May  8 2021 Remi Collet <remi@remirepo.net> - 8.0.6-3
+- get rid of inet_addr and gethostbyaddr calls
+
 * Thu May  6 2021 Remi Collet <remi@remirepo.net> - 8.0.6-2
 - get rid of inet_ntoa and inet_aton calls
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-27  7:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-27  7:31 [rpms/php] private-php86: get rid of inet_addr and gethostbyaddr calls Remi Collet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox