You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In your implementation of getsockname and getpeername there's the following code to abort if the sockaddr buffer is too small:
structsockaddr_in*result;
if (*__len<sizeof(structsockaddr_in))
{
*__len=sizeof(structsockaddr_in);
errno=EINVAL;
return-1;
}
Unfortunately, there's address families like AF_NETLINK where the corresponding sockaddr struct (sockaddr_nl) is shorter than sockaddr_in. sockaddr_in has 16 bytes on my machine, while sockaddr_nl only has 12.
So if there's an open socket of type AF_NETLINK and the program calls getsockname or getpeername on said socket, your library is always going to abort since it thinks there's not enough space.
First the socket is created with type AF_NETLINK. Then your lib receives the getsockname call with a len of 12 (which is the correct length for an AF_NETLINK socket), and since 12 is < 16 it sets errno = EINVAL and returns -1, and then the program using the library prints its error messages.
I'm going to see if I find a useful way to fix this issue.
Maybe by only checking the length if sa_family is AF_INET6, and leave the length check and error handling to the original getsockname when it's not?
The text was updated successfully, but these errors were encountered:
Sorry, yet another bug report :/
In your implementation of
getsockname
andgetpeername
there's the following code to abort if the sockaddr buffer is too small:Unfortunately, there's address families like AF_NETLINK where the corresponding sockaddr struct (sockaddr_nl) is shorter than sockaddr_in. sockaddr_in has 16 bytes on my machine, while sockaddr_nl only has 12.
So if there's an open socket of type AF_NETLINK and the program calls getsockname or getpeername on said socket, your library is always going to abort since it thinks there's not enough space.
Here's the log output:
First the socket is created with type AF_NETLINK. Then your lib receives the getsockname call with a len of 12 (which is the correct length for an AF_NETLINK socket), and since 12 is < 16 it sets
errno = EINVAL
and returns -1, and then the program using the library prints its error messages.I'm going to see if I find a useful way to fix this issue.
Maybe by only checking the length if
sa_family
isAF_INET6
, and leave the length check and error handling to the original getsockname when it's not?The text was updated successfully, but these errors were encountered: