Skip to content

Commit

Permalink
fixes #1675 undefined behavior in posix ipc_dialer_dial
Browse files Browse the repository at this point in the history
(This also affects TCP, and fixed there.)
  • Loading branch information
gdamore committed Sep 14, 2023
1 parent 12002c9 commit a8ed756
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/platform/posix/posix_ipcdial.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ ipc_dialer_dial(void *arg, nni_aio *aio)
// This arranges for the fd to be in non-blocking mode, and adds the
// poll fd to the list.
if ((rv = nni_posix_pfd_init(&pfd, fd)) != 0) {
// the error label unlocks this
nni_mtx_lock(&d->mtx);
goto error;
}

Expand Down
2 changes: 2 additions & 0 deletions src/platform/posix/posix_tcpdial.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ nni_tcp_dial(nni_tcp_dialer *d, const nni_sockaddr *sa, nni_aio *aio)
// poll fd to the list.
if ((rv = nni_posix_pfd_init(&pfd, fd)) != 0) {
(void) close(fd);
// the error label unlocks this
nni_mtx_lock(&d->mtx);
goto error;
}

Expand Down

0 comments on commit a8ed756

Please sign in to comment.