Skip to content

Socket ether linux step2 #17926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
address code concerns
  • Loading branch information
devnexen committed Jul 2, 2025
commit 120cf76628ba1959750830e4f02877104af6b818
8 changes: 4 additions & 4 deletions ext/sockets/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,7 @@ PHP_FUNCTION(socket_recvfrom)
int recv_flags = (int)arg4;
zval *addr = arg5;
zval *index = arg6;
if (recv_flags > 0 && !(recv_flags & (MSG_PEEK|MSG_DONTWAIT|MSG_ERRQUEUE))) {
if (recv_flags > 0 && (recv_flags & ~(MSG_PEEK|MSG_DONTWAIT|MSG_ERRQUEUE))) {
zend_argument_value_error(4, "must set one the flags MSG_PEEK, MSG_DONTWAIT, MSG_ERRQUEUE");
zend_string_efree(recv_buf);
RETURN_THROWS();
Expand Down Expand Up @@ -1760,7 +1760,7 @@ PHP_FUNCTION(socket_recvfrom)

switch (protocol) {
case ETH_P_IP: {
if (php_socket_get_chunk(&ether_hdr_buf, &raw_buf, 0, sizeof(struct iphdr)) == FAILURE) {
if (php_socket_get_chunk(&ether_hdr_buf, &raw_buf, ETH_HLEN, sizeof(struct iphdr)) == FAILURE) {
zval_ptr_dtor(&obj);
zend_string_efree(recv_buf);
zend_value_error("invalid ipv4 frame buffer length");
Expand Down Expand Up @@ -1821,10 +1821,10 @@ PHP_FUNCTION(socket_recvfrom)
break;
}
case ETH_P_IPV6: {
if (php_socket_get_chunk(&ether_hdr_buf, &raw_buf, ETH_HLEN, sizeof(struct iphdr)) == FAILURE) {
if (php_socket_get_chunk(&ether_hdr_buf, &raw_buf, ETH_HLEN, sizeof(struct ipv6hdr)) == FAILURE) {
zval_ptr_dtor(&obj);
zend_string_efree(recv_buf);
zend_value_error("invalid ipv4 frame buffer length");
zend_value_error("invalid ipv6 frame buffer length");
RETURN_THROWS();
}
struct ipv6hdr ip;
Expand Down