Skip to content

Commit d9db2a6

Browse files
authored
Merge pull request #898 from yosuke-wolfssl/f_404_405
Fix f_404 and f_405
2 parents 2f15238 + d0aad2b commit d9db2a6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

apps/wolfsshd/auth.c

Lines changed: 4 additions & 4 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
}
@@ -946,7 +946,7 @@ static int SetupUserTokenWin(const char* usr,
946946

947947
/* write domain name after the user name in buffer */
948948
l->DomainName.Length = (USHORT)(wcslen(dmW) * sizeof(wchar_t));
949-
l->DomainName.MaximumLength = l->UserPrincipalName.Length;
949+
l->DomainName.MaximumLength = l->DomainName.Length;
950950
l->DomainName.Buffer = (WCHAR*)((byte*)(l->UserPrincipalName.Buffer) + l->UserPrincipalName.Length);
951951
memcpy_s(l->DomainName.Buffer, l->DomainName.Length, dmW, l->DomainName.Length);
952952
}

0 commit comments

Comments
 (0)