Skip to content

Commit cf003e7

Browse files
committed
changes from review
1 parent 6ac51d8 commit cf003e7

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

ext/sockets/sockets.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,13 @@ ZEND_DECLARE_MODULE_GLOBALS(sockets)
9898
#endif
9999

100100
#if defined(ETH_P_ALL)
101-
#define PHP_ETH_PROTO_CHECK(protocol, family) \
102-
do { \
103-
/* We ll let EINVAL errno warning about miusage, too many protocols conflicts but AF_PACKET family works only with ETH_P_* constants */ \
104-
if ((protocol >= ETH_P_LOOP && protocol <= USHRT_MAX) && family == AF_PACKET) { \
105-
protocol = htons(protocol); \
106-
} \
107-
} \
108-
while (0)
101+
#define PHP_ETH_PROTO_CHECK(protocol, family) \
102+
do { \
103+
/* We ll let EINVAL errno warning about miusage, too many protocols conflicts */ \
104+
if (protocol <= USHRT_MAX && family == AF_PACKET) { \
105+
protocol = htons(protocol); \
106+
} \
107+
} while (0)
109108
#else
110109
#define PHP_ETH_PROTO_CHECK(protocol, family) (0)
111110
#endif
@@ -1180,7 +1179,7 @@ PHP_FUNCTION(socket_create)
11801179
RETURN_THROWS();
11811180
}
11821181

1183-
PHP_ETH_PROTO_CHECK(protocol, protocol);
1182+
PHP_ETH_PROTO_CHECK(protocol, domain);
11841183

11851184
object_init_ex(return_value, socket_ce);
11861185
php_sock = Z_SOCKET_P(return_value);

ext/sockets/tests/socket_afpacket.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
socket_getsockname from AF_PACKET socket
33
--EXTENSIONS--
44
sockets
5+
posix
56
--SKIPIF--
67
<?php
78

@@ -18,7 +19,7 @@ if (!function_exists("posix_getuid") || posix_getuid() != 0) {
1819
$s_bind = socket_bind($s_c, 'lo');
1920
var_dump($s_bind);
2021

21-
// Connect to destination address
22+
// sock_getsockname in this context gets the interface rather than the address.
2223
$s_conn = socket_getsockname($s_c, $istr, $iindex);
2324
var_dump($s_conn);
2425
var_dump($istr);

0 commit comments

Comments
 (0)