mirror of
https://github.com/apache/nuttx.git
synced 2026-05-29 20:56:47 +08:00
net/socket/getsockopt: move the options check to the upper layer
check parameters at the top level to avoid errors when assigning values in si_getsockopt. Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
committed by
Alin Jerpelea
parent
24d947b7c1
commit
7f0a670bde
@@ -83,13 +83,6 @@ static int psock_socketlevel_option(FAR struct socket *psock, int option,
|
|||||||
{
|
{
|
||||||
FAR struct socket_conn_s *conn = psock->s_conn;
|
FAR struct socket_conn_s *conn = psock->s_conn;
|
||||||
|
|
||||||
/* Verify that the socket option if valid (but might not be supported ) */
|
|
||||||
|
|
||||||
if (!value || !value_len)
|
|
||||||
{
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Process the options always handled locally */
|
/* Process the options always handled locally */
|
||||||
|
|
||||||
switch (option)
|
switch (option)
|
||||||
@@ -271,6 +264,13 @@ int psock_getsockopt(FAR struct socket *psock, int level, int option,
|
|||||||
{
|
{
|
||||||
int ret = -ENOPROTOOPT;
|
int ret = -ENOPROTOOPT;
|
||||||
|
|
||||||
|
/* Verify that the socket option is valid (but might not be supported ) */
|
||||||
|
|
||||||
|
if (value == NULL || value_len == NULL || *value_len == 0)
|
||||||
|
{
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Verify that the sockfd corresponds to valid, allocated socket */
|
/* Verify that the sockfd corresponds to valid, allocated socket */
|
||||||
|
|
||||||
if (psock == NULL || psock->s_conn == NULL)
|
if (psock == NULL || psock->s_conn == NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user