Skip to content
Draft
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
18 changes: 12 additions & 6 deletions ext/sockets/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -2802,14 +2802,16 @@ PHP_FUNCTION(socket_addrinfo_lookup)
// Some platforms support also PF_LOCAL/AF_UNIX (e.g. FreeBSD) but the security concerns implied
// make it not worth handling it (e.g. unwarranted write permissions on the socket).
// Note existing socket_addrinfo* api already forbid such case.
if (val != AF_UNSPEC) {
#ifdef HAVE_IPV6
if (val != AF_INET && val != AF_INET6) {
zend_argument_value_error(3, "\"ai_family\" key must be AF_INET or AF_INET6");
if (val != AF_INET && val != AF_INET6) {
zend_argument_value_error(3, "\"ai_family\" key must be AF_INET or AF_INET6");
#else
if (val != AF_INET) {
zend_argument_value_error(3, "\"ai_family\" key must be AF_INET");
if (val != AF_INET) {
zend_argument_value_error(3, "\"ai_family\" key must be AF_INET");
#endif
RETURN_THROWS();
RETURN_THROWS();
}
}
hints.ai_family = (int)val;
} else {
Expand All @@ -2833,7 +2835,11 @@ PHP_FUNCTION(socket_addrinfo_lookup)
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));

for (rp = result; rp != NULL; rp = rp->ai_next) {
if (rp->ai_family != AF_UNSPEC) {
if (rp->ai_family == AF_INET
#ifdef HAVE_IPV6
|| rp->ai_family != AF_INET6
#endif
) {
zval zaddr;

object_init_ex(&zaddr, address_info_ce);
Expand Down
7 changes: 7 additions & 0 deletions ext/sockets/sockets.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
*/
const AF_INET6 = UNKNOWN;
#endif
#ifdef AF_UNSPEC
/**
* @var int
* @cvalue AF_UNSPEC
*/
const AF_UNSPEC = UNKNOWN;
#endif
#ifdef AF_DIVERT
/**
* @var int
Expand Down
5 changes: 4 additions & 1 deletion ext/sockets/sockets_arginfo.h

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