Skip to content

Commit 727a0c8

Browse files
Fix handling of empty prompts in keyboard-interactive auth test
Co-Authored-By: andrew@wolfssl.com <andrew@wolfssl.com>
1 parent 4cc1aa5 commit 727a0c8

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

tests/auth.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,16 +425,24 @@ static int keyboardUserAuth(byte authType, WS_UserAuthData* authData, void* ctx)
425425

426426
if (authType == WOLFSSH_USERAUTH_KEYBOARD) {
427427
AssertIntEQ(kbResponseCount, authData->sf.keyboard.promptCount);
428-
for (word32 prompt = 0; prompt < kbResponseCount; prompt++) {
429-
AssertStrEQ("Password: ", authData->sf.keyboard.prompts[prompt]);
428+
429+
/* Only check prompts if there are any */
430+
if (kbResponseCount > 0) {
431+
for (word32 prompt = 0; prompt < kbResponseCount; prompt++) {
432+
AssertStrEQ("Password: ", authData->sf.keyboard.prompts[prompt]);
433+
}
430434
}
431435

432436
authData->sf.keyboard.responseCount = kbResponseCount;
433437
if (unbalanced) {
434438
authData->sf.keyboard.responseCount++;
435439
}
436-
authData->sf.keyboard.responseLengths = kbResponseLengths;
437-
authData->sf.keyboard.responses = (byte**)kbResponses;
440+
441+
/* Only set response pointers if there are responses */
442+
if (kbResponseCount > 0) {
443+
authData->sf.keyboard.responseLengths = kbResponseLengths;
444+
authData->sf.keyboard.responses = (byte**)kbResponses;
445+
}
438446
ret = WS_SUCCESS;
439447
}
440448
return ret;

0 commit comments

Comments
 (0)