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 7f1ec4c commit a54820f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/platform/posix/posix_ipcdial.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2023 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
// Copyright 2019 Devolutions <info@devolutions.net>
//
Expand Down 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
4 changes: 3 additions & 1 deletion src/platform/posix/posix_tcpdial.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2023 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
// Copyright 2018 Devolutions <info@devolutions.net>
//
Expand Down 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 a54820f

Please sign in to comment.