Skip to content

Commit d0aad2b

Browse files
Fix f_405
1 parent 087fba9 commit d0aad2b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

apps/wolfsshd/auth.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -787,17 +787,17 @@ static int CheckPasswordWIN(const char* usr, const byte* pw, word32 pwSz, WOLFSS
787787

788788
ret = WSSHD_AUTH_SUCCESS;
789789

790-
usrWSz = WSTRLEN(usr) * sizeof(WCHAR);
790+
usrWSz = WSTRLEN(usr);
791791

792-
usrW = (WCHAR*)WMALLOC((usrWSz * sizeof(WCHAR)) + sizeof(WCHAR), authCtx->heap, DYNTYPE_SSHD);
792+
usrW = (WCHAR*)WMALLOC((usrWSz + 1) * sizeof(WCHAR), authCtx->heap, DYNTYPE_SSHD);
793793
if (usrW == NULL) {
794794
wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Ran out of memory");
795795
ret = WSSHD_AUTH_FAILURE;
796796
}
797797

798798
if (ret == WSSHD_AUTH_SUCCESS) {
799799
size_t wr = 0;
800-
if (mbstowcs_s(&wr, usrW, usrWSz, usr, usrWSz-1) != 0) {
800+
if (mbstowcs_s(&wr, usrW, usrWSz + 1, usr, usrWSz) != 0) {
801801
ret = WSSHD_AUTH_FAILURE;
802802
}
803803
}

0 commit comments

Comments
 (0)