From b0cf4cfa5d247b6e099f5ce6ee165244ab3cc86c Mon Sep 17 00:00:00 2001 From: Lealem Amedie Date: Thu, 11 Jul 2024 16:56:39 -0600 Subject: [PATCH] Don't exit wolfSSHd daemon on recoverable fcntl failure --- apps/wolfsshd/wolfsshd.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/apps/wolfsshd/wolfsshd.c b/apps/wolfsshd/wolfsshd.c index 3fbcbf736..77e8fd547 100644 --- a/apps/wolfsshd/wolfsshd.c +++ b/apps/wolfsshd/wolfsshd.c @@ -2413,19 +2413,28 @@ static int StartSSHD(int argc, char** argv) #ifdef USE_WINDOWS_API unsigned long blocking = 1; if (ioctlsocket(conn->fd, FIONBIO, &blocking) - == SOCKET_ERROR) - err_sys("ioctlsocket failed"); + == SOCKET_ERROR) { + WLOG(WS_LOG_DEBUG, "wolfSSH non-fatal error: " + "ioctlsocket failed"); + continue; + } #elif defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET) \ || defined (WOLFSSL_TIRTOS)|| defined(WOLFSSL_VXWORKS) || \ defined(WOLFSSL_NUCLEUS) /* non blocking not supported, for now */ #else int flags = fcntl(conn->fd, F_GETFL, 0); - if (flags < 0) - err_sys("fcntl get failed"); + if (flags < 0) { + WLOG(WS_LOG_DEBUG, "wolfSSH non-fatal error: " + "fcntl get failed"); + continue; + } flags = fcntl(conn->fd, F_SETFL, flags | O_NONBLOCK); - if (flags < 0) - err_sys("fcntl set failed"); + if (flags < 0) { + WLOG(WS_LOG_DEBUG, "wolfSSH non-fatal error: " + "fcntl set failed"); + continue; + } #endif } ret = NewConnection(conn);