Skip to content

Commit 4700799

Browse files
committed
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
1 parent f24c3c2 commit 4700799

1 file changed

Lines changed: 12 additions & 14 deletions

File tree

apps/wolfsshd/wolfsshd.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,20 +1347,18 @@ static int SHELL_Subsystem(WOLFSSHD_CONNECTION* conn, WOLFSSH* ssh,
13471347
setenv("LOGNAME", pPasswd->pw_name, 1);
13481348
setenv("SHELL", pPasswd->pw_shell, 1);
13491349

1350-
if (pPasswd->pw_shell) {
1351-
if (WSTRLEN(pPasswd->pw_shell) < sizeof(shell)) {
1352-
char* cursor;
1353-
char* start;
1354-
1355-
WSTRNCPY(shell, pPasswd->pw_shell, sizeof(shell));
1356-
cursor = shell;
1357-
do {
1358-
start = cursor;
1359-
*cursor = '-';
1360-
cursor = WSTRCHR(start, '/');
1361-
} while (cursor && *cursor != '\0');
1362-
args[0] = start;
1363-
}
1350+
if (WSTRLEN(pPasswd->pw_shell) < sizeof(shell)) {
1351+
char* cursor;
1352+
char* start;
1353+
1354+
WSTRNCPY(shell, pPasswd->pw_shell, sizeof(shell));
1355+
cursor = shell;
1356+
do {
1357+
start = cursor;
1358+
*cursor = '-';
1359+
cursor = WSTRCHR(start, '/');
1360+
} while (cursor && *cursor != '\0');
1361+
args[0] = start;
13641362
}
13651363

13661364
rc = chdir(pPasswd->pw_dir);

0 commit comments

Comments
 (0)