Skip to content

Commit 07f901d

Browse files
authored
Merge pull request #504 from ejohnstown/shadowfix
wolfSSHd Shadow Fix
2 parents 17e8373 + f74c2db commit 07f901d

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

apps/wolfsshd/auth.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ static int CheckPasswordHashUnix(const char* input, char* stored)
292292
{
293293
int ret = WSSHD_AUTH_SUCCESS;
294294
char* hashedInput;
295+
word32 hashedInputSz = 0, storedSz = 0;
295296

296297
if (input == NULL || stored == NULL) {
297298
ret = WS_BAD_ARGUMENT;
@@ -303,7 +304,13 @@ static int CheckPasswordHashUnix(const char* input, char* stored)
303304
ret = WS_FATAL_ERROR;
304305
}
305306
else {
306-
if (WMEMCMP(hashedInput, stored, WSTRLEN(stored)) != 0) {
307+
hashedInputSz = (word32)WSTRLEN(hashedInput);
308+
storedSz = (word32)WSTRLEN(stored);
309+
310+
if (storedSz == 0 || stored[0] == '*' ||
311+
hashedInputSz == 0 || hashedInput[0] == '*' ||
312+
hashedInputSz != storedSz ||
313+
WMEMCMP(hashedInput, stored, storedSz) != 0) {
307314
ret = WSSHD_AUTH_FAILURE;
308315
}
309316
}

0 commit comments

Comments
 (0)