mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 21:34:07 +08:00
net/getsockname: small addrlen should be a valid value
fix usrsock getsockname fail
nsh> usrsocktest
...
Testing group "basic_getsockname" =>
[TEST ASSERT FAILED!]
In function "basic_getsockname_open":
line 170: Assertion `(ssize_t)((ret)) == (ssize_t)((0))' failed.
got value: -1
should be: 0
Group "basic_getsockname": [FAILED]
...
Reference:
GETSOCKNAME(2)
NAME
getsockname - get socket name
...
DESCRIPTION
...
The returned address is truncated if the buffer provided is too small;
in this case, addrlen will return a value greater than was supplied to the call.
Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
@@ -88,7 +88,7 @@ int psock_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr,
|
||||
|
||||
/* Some sanity checking... */
|
||||
|
||||
if (addr == NULL || addrlen == NULL || *addrlen <= 0)
|
||||
if (addr == NULL || addrlen == NULL)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user