diff options
author | Joseph Sutton <josephsutton@catalyst.net.nz> | 2023-01-10 13:06:25 +1300 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2023-01-10 20:22:32 +0000 |
commit | cbe6fb38ec13adbe06667f16241d61d4e2a80545 (patch) | |
tree | f97a79c94e3fe323db3b3cf8e36f3ae680933eef /lib/util | |
parent | 01bd234f6af37641017a00da0dec729928ad3060 (diff) | |
download | samba-cbe6fb38ec13adbe06667f16241d61d4e2a80545.tar.gz |
lib/tfork: Don't overwrite 'ret' in cleanup phase
The cleanup phase of tfork_create() saves errno prior to calling
functions that might modify it, with the intention of restoring it
afterwards. However, the value of 'ret' is accidentally overwritten. It
will always be equal to 0, and hence errno will not be restored.
Fix this by introducing a new variable, ret2, for calling functions in
the cleanup phase.
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/util')
-rw-r--r-- | lib/util/tfork.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/util/tfork.c b/lib/util/tfork.c index 9867543702e..57a4e18638b 100644 --- a/lib/util/tfork.c +++ b/lib/util/tfork.c @@ -739,8 +739,9 @@ struct tfork *tfork_create(void) struct tfork_state *state = NULL; struct tfork *t = NULL; pid_t pid; - int saved_errno; + int saved_errno = 0; int ret = 0; + int ret2; #ifdef HAVE_PTHREAD ret = pthread_once(&tfork_global_is_initialized, @@ -816,16 +817,16 @@ cleanup: close(t->event_fd); } - ret = tfork_create_reap_waiter(state->waiter_pid); - assert(ret == 0); + ret2 = tfork_create_reap_waiter(state->waiter_pid); + assert(ret2 == 0); free(t); t = NULL; } } - ret = tfork_uninstall_sigchld_handler(); - assert(ret == 0); + ret2 = tfork_uninstall_sigchld_handler(); + assert(ret2 == 0); tfork_global_free(); |