From 4d46e89168361ff7608c668a3ea9fc9130af8cf1 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 11 Jan 2025 18:02:53 +0000 Subject: [PATCH] removes support for getpeername, indeed does not make sense for so low level sockets.. --- ext/sockets/sockets.c | 22 ---------------------- ext/sockets/tests/socket_afpacket.phpt | 4 ++++ 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index ac88e81a4cf21..313af2f6a5fb1 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -1077,9 +1077,6 @@ PHP_FUNCTION(socket_getpeername) struct sockaddr_in *sin; #ifdef HAVE_IPV6 struct sockaddr_in6 *sin6; -#endif -#ifdef AF_PACKET - struct sockaddr_ll *sll; #endif char addrbuf[INET6_ADDRSTRLEN]; struct sockaddr_un *s_un; @@ -1136,25 +1133,6 @@ PHP_FUNCTION(socket_getpeername) ZEND_TRY_ASSIGN_REF_STRING(arg2, s_un->sun_path); RETURN_TRUE; break; -#ifdef AF_PACKET - case AF_PACKET: - sll = (struct sockaddr_ll *) sa; - char ifrname[IFNAMSIZ]; - - if (UNEXPECTED(!if_indextoname(sll->sll_ifindex, ifrname))) { - zend_throw_error(NULL, "invalid interface index"); - RETURN_THROWS(); - } - - ZEND_TRY_ASSIGN_REF_STRING(arg2, ifrname); - - if (arg3 != NULL) { - ZEND_TRY_ASSIGN_REF_LONG(arg3, sll->sll_ifindex); - } - RETURN_TRUE; - break; -#endif - default: zend_argument_value_error(1, "must be one of AF_UNIX, AF_INET, or AF_INET6"); diff --git a/ext/sockets/tests/socket_afpacket.phpt b/ext/sockets/tests/socket_afpacket.phpt index 9240833a004ca..50796aad419c8 100644 --- a/ext/sockets/tests/socket_afpacket.phpt +++ b/ext/sockets/tests/socket_afpacket.phpt @@ -23,6 +23,8 @@ if (!function_exists("posix_getuid") || posix_getuid() != 0) { var_dump($s_conn); var_dump($istr); var_dump($iindex); + + socket_getpeername($s_c, $istr2, $iindex2); socket_close($s_c); ?> --EXPECTF-- @@ -30,3 +32,5 @@ bool(true) bool(true) string(2) "lo" int(%i) + +Warning: socket_getpeername(): unable to retrieve peer name [95]: Operation not supported in %s on line %d