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:
parent
d17d877764
commit
9732334b5d
1 changed files with 5 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue