Skip to content

Commit 35e2212

Browse files
committed
little buffer adjustments boundaries before more important changes.
1 parent 3a33edc commit 35e2212

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
@@ -1547,8 +1547,11 @@ PHP_FUNCTION(socket_recvfrom)
15471547
}
15481548

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

@@ -1783,6 +1786,15 @@ PHP_FUNCTION(socket_sendto)
17831786
RETURN_THROWS();
17841787
}
17851788

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

0 commit comments

Comments
 (0)