From 304955ff94cf63f5bd8e02ec006cfdb5d8f2cf98 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Thu, 4 Jun 2026 13:48:31 -0700 Subject: [PATCH] Move unsafe call out of signal handler Cleanup clang-tidy bugprone-signal-handler findings. - wolfsshd: drop fprintf from interruptCatch; the main accept loop logs "Closing down wolfSSHD" after seeing quit set. - sftpclient: annotate wolfSSH_SFTP_Interrupt call in sig_handler with NOLINT, since the function is only a single byte store and is safe to call from a signal handler. --- apps/wolfsshd/wolfsshd.c | 5 +++-- examples/sftpclient/sftpclient.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/wolfsshd/wolfsshd.c b/apps/wolfsshd/wolfsshd.c index f841f6a5..4389e277 100644 --- a/apps/wolfsshd/wolfsshd.c +++ b/apps/wolfsshd/wolfsshd.c @@ -203,8 +203,6 @@ static void ShowUsage(void) static void interruptCatch(int in) { (void)in; - if (logFile) - fprintf(logFile, "Closing down wolfSSHD\n"); quit = 1; } @@ -2762,6 +2760,9 @@ static int StartSSHD(int argc, char** argv) } #endif } + if (quit && logFile) { + fprintf(logFile, "Closing down wolfSSHD\n"); + } } #ifdef _WIN32 diff --git a/examples/sftpclient/sftpclient.c b/examples/sftpclient/sftpclient.c index 8cec824b..b7e7c332 100644 --- a/examples/sftpclient/sftpclient.c +++ b/examples/sftpclient/sftpclient.c @@ -268,7 +268,7 @@ static void sig_handler(const int sig) (void)sig; interrupt = 1; - wolfSSH_SFTP_Interrupt(ssh); + wolfSSH_SFTP_Interrupt(ssh); /* NOLINT(bugprone-signal-handler) */ } #endif /* WS_NO_SIGNAL */