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 e221d7b5bd911ed8f4d061e5dbc1d562d1cbcabf Author: Marco Casaroli <[email protected]> AuthorDate: Thu Nov 26 18:51:36 2026 +0100 net/local: Do not find the ends of a socket pair by name. local_findconn() finds a local socket by its name for bind(), connect() and sendto() of a datagram socket. It also compared the internal name of a socket pair. So connect() of a datagram socket to the name "socketpairN" succeeded, a sendto() to it found an end of the pair, and bind() of that name failed with EADDRINUSE. A socket pair has no name for the program: getsockname() gives an unnamed address. Now local_findconn() skips the ends of socket pairs: a pair end is found only through its pair. connect() and sendto() to the name fail with ENOENT, as for any name with no socket, and bind() of the name succeeds. local_peerconn() matches a pair end only with a pair end, so a socket bound to that name is never taken for the peer of a pair. The behavior is the same in all build modes. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- net/local/local_conn.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/local/local_conn.c b/net/local/local_conn.c index d7d1661bc8d..be3990421e1 100644 --- a/net/local/local_conn.c +++ b/net/local/local_conn.c @@ -119,7 +119,11 @@ local_findconn(FAR const struct local_conn_s *local_conn, while ((conn = local_nextconn(conn)) != NULL) { - if (local_conn->lc_proto == conn->lc_proto && + /* The name of a socket pair is internal: a pair end is found only + * through its pair. + */ + + if (local_conn->lc_proto == conn->lc_proto && !conn->lc_pair && strncmp(conn->lc_path, &unaddr->sun_path[index], UNIX_PATH_MAX - 1) == 0) { @@ -148,6 +152,7 @@ FAR struct local_conn_s *local_peerconn(FAR struct local_conn_s *conn) while ((peer = local_nextconn(peer)) != NULL) { if (conn->lc_proto == peer->lc_proto && conn != peer && + conn->lc_pair == peer->lc_pair && !strncmp(conn->lc_path, peer->lc_path, UNIX_PATH_MAX - 1)) { return peer;
