This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit b2dee66eb908e6aec7290e54b95a6774c9aa2c71 Author: wenquan1 <[email protected]> AuthorDate: Mon Apr 20 20:27:04 2026 +0800 net/local: set lc_peer in local_socketpair local_socketpair() creates a pair of connected local sockets but does not set the lc_peer pointer on either connection. This causes a NULL pointer dereference when getpeername() is called on a socketpair endpoint, because local_getpeername() accesses conn->lc_peer->lc_type without a NULL check. Fix by assigning conns[0]->lc_peer = conns[1] and vice versa before marking the connections as LOCAL_STATE_CONNECTED, consistent with the peer assignment in local_alloc_accept(). Signed-off-by: wenquan1 <[email protected]> --- net/local/local_sockif.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/local/local_sockif.c b/net/local/local_sockif.c index 21652f2ac6f..8659342d82d 100644 --- a/net/local/local_sockif.c +++ b/net/local/local_sockif.c @@ -1192,6 +1192,11 @@ static int local_socketpair(FAR struct socket *psocks[2]) goto errout; } + /* Set up peer references so that getpeername() works correctly */ + + conns[0]->lc_peer = conns[1]; + conns[1]->lc_peer = conns[0]; + conns[0]->lc_state = conns[1]->lc_state = LOCAL_STATE_CONNECTED;
