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:
SPRESENSE 2021-07-30 14:45:01 +09:00 committed by Xiang Xiao
parent d17d877764
commit 9732334b5d

View file

@ -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;