net/udp:add check of the ip packet length

Signed-off-by: wangchen <wangchen41@xiaomi.com>
This commit is contained in:
wangchen 2023-08-03 11:14:53 +08:00 committed by Xiang Xiao
parent dea3346d0b
commit 842b6b88d3
1 changed files with 7 additions and 0 deletions

View File

@ -541,6 +541,13 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf,
conn = psock->s_conn;
DEBUGASSERT(conn);
/* The length of a datagram to be up to 65,535 octets */
if (len > 65535)
{
return -EMSGSIZE;
}
/* If the UDP socket was previously assigned a remote peer address via
* connect(), then as with connection-mode socket, sendto() may not be
* used with a non-NULL destination address. Normally send() would be