Skip to content

Commit 30eecc1

Browse files
committed
little buffer adjustments boundaries before more important changes.
1 parent daa00b0 commit 30eecc1

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

ext/sockets/sockets.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,8 +1545,11 @@ PHP_FUNCTION(socket_recvfrom)
15451545
}
15461546

15471547
#ifdef AF_PACKET
1548-
if (php_sock->type == AF_PACKET && arg3 < 2048) {
1549-
RETURN_FALSE;
1548+
// ethernet header + payload
1549+
// possibly follow-up PR SOCK_DGRAM
1550+
if (php_sock->type == AF_PACKET && arg3 < 1514) {
1551+
zend_argument_value_error(3, "must be at least 1514 for AF_PACKET");
1552+
RETURN_THROWS();
15501553
}
15511554
#endif
15521555

@@ -1782,6 +1785,15 @@ PHP_FUNCTION(socket_sendto)
17821785
RETURN_THROWS();
17831786
}
17841787

1788+
#ifdef AF_PACKET
1789+
// ether header + payload
1790+
// TODO dealing with SOCK_DGRAM
1791+
if (php_sock->type == AF_PACKET && len < 60) {
1792+
zend_argument_value_error(3, "must be at least 64 for AF_PACKET");
1793+
RETURN_THROWS();
1794+
}
1795+
#endif
1796+
17851797
switch (php_sock->type) {
17861798
case AF_UNIX:
17871799
memset(&s_un, 0, sizeof(s_un));

0 commit comments

Comments
 (0)