Skip to content

Commit 6606cc0

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Fix GH-7748: gethostbyaddr outputs binary string
2 parents 25bb229 + 7daf012 commit 6606cc0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ext/standard/dns.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,14 @@ static zend_string *php_gethostbyaddr(char *ip)
182182
if (inet_pton(AF_INET6, ip, &sa6.sin6_addr)) {
183183
sa6.sin6_family = AF_INET6;
184184

185-
if (getnameinfo((struct sockaddr *)&sa6, sizeof(sa6), out, sizeof(out), NULL, 0, NI_NAMEREQD) < 0) {
185+
if (getnameinfo((struct sockaddr *)&sa6, sizeof(sa6), out, sizeof(out), NULL, 0, NI_NAMEREQD) != 0) {
186186
return zend_string_init(ip, strlen(ip), 0);
187187
}
188188
return zend_string_init(out, strlen(out), 0);
189189
} else if (inet_pton(AF_INET, ip, &sa4.sin_addr)) {
190190
sa4.sin_family = AF_INET;
191191

192-
if (getnameinfo((struct sockaddr *)&sa4, sizeof(sa4), out, sizeof(out), NULL, 0, NI_NAMEREQD) < 0) {
192+
if (getnameinfo((struct sockaddr *)&sa4, sizeof(sa4), out, sizeof(out), NULL, 0, NI_NAMEREQD) != 0) {
193193
return zend_string_init(ip, strlen(ip), 0);
194194
}
195195
return zend_string_init(out, strlen(out), 0);

0 commit comments

Comments
 (0)