net: Split msg_iovlen check in recvmsg into each protocol

To prepare for supporting multiple iov in each protocol.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
Zhe Weng 2024-10-22 15:45:11 +08:00 committed by Xiang Xiao
parent 4d17c353dd
commit 87a7714103
12 changed files with 55 additions and 5 deletions

View file

@ -330,6 +330,11 @@ ssize_t bluetooth_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
return -EPROTONOSUPPORT; return -EPROTONOSUPPORT;
} }
if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}
/* Perform the packet recvmsg() operation */ /* Perform the packet recvmsg() operation */
/* Initialize the state structure. This is done with the network /* Initialize the state structure. This is done with the network

View file

@ -526,6 +526,11 @@ ssize_t can_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
return -ENOSYS; return -ENOSYS;
} }
if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}
net_lock(); net_lock();
/* Initialize the state structure. */ /* Initialize the state structure. */

View file

@ -296,6 +296,11 @@ ssize_t icmp_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
/* Some sanity checks */ /* Some sanity checks */
if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}
DEBUGASSERT(buf != NULL); DEBUGASSERT(buf != NULL);
if (len < ICMP_HDRLEN) if (len < ICMP_HDRLEN)

View file

@ -307,6 +307,11 @@ ssize_t icmpv6_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
/* Some sanity checks */ /* Some sanity checks */
if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}
DEBUGASSERT(buf != NULL); DEBUGASSERT(buf != NULL);
if (len < ICMPv6_HDRLEN) if (len < ICMPv6_HDRLEN)

View file

@ -330,6 +330,11 @@ ssize_t ieee802154_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
return -EPROTONOSUPPORT; return -EPROTONOSUPPORT;
} }
if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}
/* Perform the packet recvfrom() operation */ /* Perform the packet recvfrom() operation */
/* Initialize the state structure. This is done with the network /* Initialize the state structure. This is done with the network

View file

@ -2273,6 +2273,11 @@ static ssize_t inet_recvmsg(FAR struct socket *psock,
{ {
ssize_t ret; ssize_t ret;
if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}
/* If a 'from' address has been provided, verify that it is large /* If a 'from' address has been provided, verify that it is large
* enough to hold this address family. * enough to hold this address family.
*/ */

View file

@ -552,6 +552,11 @@ ssize_t local_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
return 0; return 0;
} }
if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}
DEBUGASSERT(buf); DEBUGASSERT(buf);
/* Check for a stream socket */ /* Check for a stream socket */

View file

@ -680,6 +680,11 @@ static ssize_t netlink_recvmsg(FAR struct socket *psock,
DEBUGASSERT(from == NULL || DEBUGASSERT(from == NULL ||
(fromlen != NULL && *fromlen >= sizeof(struct sockaddr_nl))); (fromlen != NULL && *fromlen >= sizeof(struct sockaddr_nl)));
if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}
/* Find the response to this message. The return value */ /* Find the response to this message. The return value */
entry = netlink_tryget_response(psock->s_conn); entry = netlink_tryget_response(psock->s_conn);

View file

@ -410,6 +410,11 @@ ssize_t pkt_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
return -EINVAL; return -EINVAL;
} }
if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}
if (psock->s_type != SOCK_RAW) if (psock->s_type != SOCK_RAW)
{ {
nerr("ERROR: Unsupported socket type: %d\n", psock->s_type); nerr("ERROR: Unsupported socket type: %d\n", psock->s_type);

View file

@ -1240,6 +1240,11 @@ static ssize_t rpmsg_socket_recvmsg(FAR struct socket *psock,
size_t len = msg->msg_iov->iov_len; size_t len = msg->msg_iov->iov_len;
ssize_t ret; ssize_t ret;
if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}
if (psock->s_type != SOCK_STREAM && if (psock->s_type != SOCK_STREAM &&
_SS_ISBOUND(conn->sconn.s_flags) && _SS_ISBOUND(conn->sconn.s_flags) &&
!_SS_ISCONNECTED(conn->sconn.s_flags)) !_SS_ISCONNECTED(conn->sconn.s_flags))

View file

@ -88,11 +88,6 @@ ssize_t psock_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
return -EINVAL; return -EINVAL;
} }
if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}
/* Verify that the sockfd corresponds to valid, allocated socket */ /* Verify that the sockfd corresponds to valid, allocated socket */
if (psock == NULL || psock->s_conn == NULL) if (psock == NULL || psock->s_conn == NULL)

View file

@ -222,6 +222,11 @@ ssize_t usrsock_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
socklen_t outaddrlen = 0; socklen_t outaddrlen = 0;
ssize_t ret; ssize_t ret;
if (msg->msg_iovlen != 1)
{
return -ENOTSUP;
}
if (fromlen) if (fromlen)
{ {
if (*fromlen > 0 && from == NULL) if (*fromlen > 0 && from == NULL)