Skip to content

Commit 4f6f79f

Browse files
authored
wincred: Avoid memory corruption (#5856)
2 parents ade1f1c + 8e4b968 commit 4f6f79f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

contrib/credential/wincred/git-credential-wincred.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static void get_credential(void)
165165
write_item("username", creds[i]->UserName,
166166
creds[i]->UserName ? wcslen(creds[i]->UserName) : 0);
167167
if (creds[i]->CredentialBlobSize > 0) {
168-
secret = xmalloc(creds[i]->CredentialBlobSize);
168+
secret = xmalloc(creds[i]->CredentialBlobSize + sizeof(WCHAR));
169169
wcsncpy_s(secret, creds[i]->CredentialBlobSize, (LPCWSTR)creds[i]->CredentialBlob, creds[i]->CredentialBlobSize / sizeof(WCHAR));
170170
line = wcstok_s(secret, L"\r\n", &remaining_lines);
171171
write_item("password", line, line ? wcslen(line) : 0);

0 commit comments

Comments
 (0)