mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
net/socket: Fix bug that sendto did not return an error
When `tolen` is not 0 and `to` is NULL, it causes illegal buffer access. Add a parameter check in this condition.
This commit is contained in:
@@ -110,6 +110,11 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
|
||||
struct iovec iov;
|
||||
struct msghdr msg;
|
||||
|
||||
if (tolen != 0 && to == NULL)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
iov.iov_base = (FAR void *)buf;
|
||||
iov.iov_len = len;
|
||||
msg.msg_name = (FAR struct sockaddr *)to;
|
||||
|
||||
Reference in New Issue
Block a user