This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 77dc0eddbe6b69c59fdabebd752d335dc7e691d8 Author: Marco Casaroli <[email protected]> AuthorDate: Thu Nov 26 18:52:14 2026 +0100 net/netlink: Check the address length of bind() and connect(). bind() and connect() of a netlink socket did not check the length of the address: only a debug check named a length shorter than struct sockaddr_nl, and the functions read the whole structure. Linux returns EINVAL for such a length. Now both functions return EINVAL when the length is shorter than struct sockaddr_nl. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- net/netlink/netlink_sockif.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/net/netlink/netlink_sockif.c b/net/netlink/netlink_sockif.c index 1d9dd4e6812..a02bccb515f 100644 --- a/net/netlink/netlink_sockif.c +++ b/net/netlink/netlink_sockif.c @@ -259,7 +259,10 @@ static int netlink_bind(FAR struct socket *psock, FAR struct sockaddr_nl *nladdr; FAR struct netlink_conn_s *conn; - DEBUGASSERT(addrlen >= sizeof(struct sockaddr_nl)); + if (addrlen < sizeof(struct sockaddr_nl)) + { + return -EINVAL; + } /* Save the address information in the connection structure */ @@ -397,7 +400,10 @@ static int netlink_connect(FAR struct socket *psock, FAR struct sockaddr_nl *nladdr; FAR struct netlink_conn_s *conn; - DEBUGASSERT(addrlen >= sizeof(struct sockaddr_nl)); + if (addrlen < sizeof(struct sockaddr_nl)) + { + return -EINVAL; + } /* Save the address information in the connection structure */
