Skip to content

Commit

Permalink
net: Split msg_iovlen check in recvmsg into each protocol
Browse files Browse the repository at this point in the history
To prepare for supporting multiple iov in each protocol.

Signed-off-by: Zhe Weng <[email protected]>
  • Loading branch information
wengzhe authored and xiaoxiang781216 committed Jan 20, 2025
1 parent 4d17c35 commit 87a7714
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 5 deletions.
5 changes: 5 additions & 0 deletions net/bluetooth/bluetooth_recvmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,11 @@ ssize_t bluetooth_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
return -EPROTONOSUPPORT;
}

if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}

/* Perform the packet recvmsg() operation */

/* Initialize the state structure. This is done with the network
Expand Down
5 changes: 5 additions & 0 deletions net/can/can_recvmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,11 @@ ssize_t can_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
return -ENOSYS;
}

if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}

net_lock();

/* Initialize the state structure. */
Expand Down
5 changes: 5 additions & 0 deletions net/icmp/icmp_recvmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ ssize_t icmp_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,

/* Some sanity checks */

if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}

DEBUGASSERT(buf != NULL);

if (len < ICMP_HDRLEN)
Expand Down
5 changes: 5 additions & 0 deletions net/icmpv6/icmpv6_recvmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ ssize_t icmpv6_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,

/* Some sanity checks */

if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}

DEBUGASSERT(buf != NULL);

if (len < ICMPv6_HDRLEN)
Expand Down
5 changes: 5 additions & 0 deletions net/ieee802154/ieee802154_recvmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,11 @@ ssize_t ieee802154_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
return -EPROTONOSUPPORT;
}

if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}

/* Perform the packet recvfrom() operation */

/* Initialize the state structure. This is done with the network
Expand Down
5 changes: 5 additions & 0 deletions net/inet/inet_sockif.c
Original file line number Diff line number Diff line change
Expand Up @@ -2273,6 +2273,11 @@ static ssize_t inet_recvmsg(FAR struct socket *psock,
{
ssize_t ret;

if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}

/* If a 'from' address has been provided, verify that it is large
* enough to hold this address family.
*/
Expand Down
5 changes: 5 additions & 0 deletions net/local/local_recvmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,11 @@ ssize_t local_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
return 0;
}

if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}

DEBUGASSERT(buf);

/* Check for a stream socket */
Expand Down
5 changes: 5 additions & 0 deletions net/netlink/netlink_sockif.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,11 @@ static ssize_t netlink_recvmsg(FAR struct socket *psock,
DEBUGASSERT(from == NULL ||
(fromlen != NULL && *fromlen >= sizeof(struct sockaddr_nl)));

if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}

/* Find the response to this message. The return value */

entry = netlink_tryget_response(psock->s_conn);
Expand Down
5 changes: 5 additions & 0 deletions net/pkt/pkt_recvmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,11 @@ ssize_t pkt_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
return -EINVAL;
}

if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}

if (psock->s_type != SOCK_RAW)
{
nerr("ERROR: Unsupported socket type: %d\n", psock->s_type);
Expand Down
5 changes: 5 additions & 0 deletions net/rpmsg/rpmsg_sockif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,11 @@ static ssize_t rpmsg_socket_recvmsg(FAR struct socket *psock,
size_t len = msg->msg_iov->iov_len;
ssize_t ret;

if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}

if (psock->s_type != SOCK_STREAM &&
_SS_ISBOUND(conn->sconn.s_flags) &&
!_SS_ISCONNECTED(conn->sconn.s_flags))
Expand Down
5 changes: 0 additions & 5 deletions net/socket/recvmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ ssize_t psock_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
return -EINVAL;
}

if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}

/* Verify that the sockfd corresponds to valid, allocated socket */

if (psock == NULL || psock->s_conn == NULL)
Expand Down
5 changes: 5 additions & 0 deletions net/usrsock/usrsock_recvmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ ssize_t usrsock_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
socklen_t outaddrlen = 0;
ssize_t ret;

if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}

if (fromlen)
{
if (*fromlen > 0 && from == NULL)
Expand Down

0 comments on commit 87a7714

Please sign in to comment.