From 4700799fccc68a33e49b4fdfe176a727199d6222 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Mon, 14 Jul 2025 15:48:30 -0700 Subject: [PATCH] Coverity: Dereference before null check 1. After getting the user's pw info, don't check that the shell value is null. We've already use it at that point. Fixes CID: 572919 --- apps/wolfsshd/wolfsshd.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/apps/wolfsshd/wolfsshd.c b/apps/wolfsshd/wolfsshd.c index 8b235f0a..0b1eb1e6 100644 --- a/apps/wolfsshd/wolfsshd.c +++ b/apps/wolfsshd/wolfsshd.c @@ -1347,20 +1347,18 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh, setenv("LOGNAME", pPasswd->pw_name, 1); setenv("SHELL", pPasswd->pw_shell, 1); - if (pPasswd->pw_shell) { - if (WSTRLEN(pPasswd->pw_shell) < sizeof(shell)) { - char* cursor; - char* start; + if (WSTRLEN(pPasswd->pw_shell) < sizeof(shell)) { + char* cursor; + char* start; - WSTRNCPY(shell, pPasswd->pw_shell, sizeof(shell)); - cursor = shell; - do { - start = cursor; - *cursor = '-'; - cursor = WSTRCHR(start, '/'); - } while (cursor && *cursor != '\0'); - args[0] = start; - } + WSTRNCPY(shell, pPasswd->pw_shell, sizeof(shell)); + cursor = shell; + do { + start = cursor; + *cursor = '-'; + cursor = WSTRCHR(start, '/'); + } while (cursor && *cursor != '\0'); + args[0] = start; } rc = chdir(pPasswd->pw_dir);