Skip to content

Commit 120cf76

Browse files
committed
address code concerns
1 parent 423bfb7 commit 120cf76

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ext/sockets/sockets.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,7 @@ PHP_FUNCTION(socket_recvfrom)
16961696
int recv_flags = (int)arg4;
16971697
zval *addr = arg5;
16981698
zval *index = arg6;
1699-
if (recv_flags > 0 && !(recv_flags & (MSG_PEEK|MSG_DONTWAIT|MSG_ERRQUEUE))) {
1699+
if (recv_flags > 0 && (recv_flags & ~(MSG_PEEK|MSG_DONTWAIT|MSG_ERRQUEUE))) {
17001700
zend_argument_value_error(4, "must set one the flags MSG_PEEK, MSG_DONTWAIT, MSG_ERRQUEUE");
17011701
zend_string_efree(recv_buf);
17021702
RETURN_THROWS();
@@ -1760,7 +1760,7 @@ PHP_FUNCTION(socket_recvfrom)
17601760

17611761
switch (protocol) {
17621762
case ETH_P_IP: {
1763-
if (php_socket_get_chunk(&ether_hdr_buf, &raw_buf, 0, sizeof(struct iphdr)) == FAILURE) {
1763+
if (php_socket_get_chunk(&ether_hdr_buf, &raw_buf, ETH_HLEN, sizeof(struct iphdr)) == FAILURE) {
17641764
zval_ptr_dtor(&obj);
17651765
zend_string_efree(recv_buf);
17661766
zend_value_error("invalid ipv4 frame buffer length");
@@ -1821,10 +1821,10 @@ PHP_FUNCTION(socket_recvfrom)
18211821
break;
18221822
}
18231823
case ETH_P_IPV6: {
1824-
if (php_socket_get_chunk(&ether_hdr_buf, &raw_buf, ETH_HLEN, sizeof(struct iphdr)) == FAILURE) {
1824+
if (php_socket_get_chunk(&ether_hdr_buf, &raw_buf, ETH_HLEN, sizeof(struct ipv6hdr)) == FAILURE) {
18251825
zval_ptr_dtor(&obj);
18261826
zend_string_efree(recv_buf);
1827-
zend_value_error("invalid ipv4 frame buffer length");
1827+
zend_value_error("invalid ipv6 frame buffer length");
18281828
RETURN_THROWS();
18291829
}
18301830
struct ipv6hdr ip;

0 commit comments

Comments
 (0)