diff options
author | Ingo Klöcker <[email protected]> | 2008-10-05 12:30:43 +0000 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2019-04-23 23:13:02 +0900 |
commit | 2547da78d6cfcd68c2789c81ba6e761ace7496db (patch) | |
tree | 3fed637783ffe5eaab85bf187f24405d1f718a97 /tdeioslave/imap4 | |
parent | 8a072e81fe2f426b84aa1ebb67b08daad20e5d7c (diff) | |
download | tdepim-2547da78d6cfcd68c2789c81ba6e761ace7496db.tar.gz tdepim-2547da78d6cfcd68c2789c81ba6e761ace7496db.zip |
A signal handler that calls for example waitpid has to save errno before and
restore it afterwards.
Cherry-picked from: 70b4927d847f52c865e0c6c91323eeb3295a99eb
Signed-off-by: Luke Dashjr <[email protected]>
(cherry picked from commit c80147f2213e3e0cac48bc80aaef7f426985720b)
Diffstat (limited to 'tdeioslave/imap4')
-rw-r--r-- | tdeioslave/imap4/imap4.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tdeioslave/imap4/imap4.cc b/tdeioslave/imap4/imap4.cc index 8ce20769c..87a6b9c43 100644 --- a/tdeioslave/imap4/imap4.cc +++ b/tdeioslave/imap4/imap4.cc @@ -71,6 +71,7 @@ imap://server/folder/ #include <signal.h> #include <sys/types.h> #include <sys/wait.h> +#include <errno.h> #ifdef HAVE_LIBSASL2 extern "C" { @@ -147,6 +148,10 @@ kdemain (int argc, char **argv) void sigchld_handler (int signo) { + // A signal handler that calls for example waitpid has to save errno + // before and restore it afterwards. + // (cf. https://www.securecoding.cert.org/confluence/display/cplusplus/ERR32-CPP.+Do+not+rely+on+indeterminate+values+of+errno) + const int save_errno = errno; int pid, status; while (signo == SIGCHLD) @@ -158,9 +163,11 @@ sigchld_handler (int signo) // the signal occurred ( BSD handles it different, but it should do // no harm ). signal (SIGCHLD, sigchld_handler); - return; + break; } } + + errno = save_errno; } IMAP4Protocol::IMAP4Protocol (const TQCString & pool, const TQCString & app, bool isSSL):TCPSlaveBase ((isSSL ? 993 : 143), |