net/socket/bind: make sure that an address was provided

1. make sure that an address was provided on bind() call
2. correct the return value if bad socket handler

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2023-08-29 15:29:17 +08:00 committed by Xiang Xiao
parent b005f844f5
commit 6340154f97

View File

@ -82,7 +82,14 @@ int psock_bind(FAR struct socket *psock, const struct sockaddr *addr,
if (!psock || psock->s_conn == NULL)
{
return -ENOTSOCK;
return -EBADF;
}
/* Make sure that an address was provided */
if (addr == NULL)
{
return -EFAULT;
}
/* Let the address family's connect() method handle the operation */