Fix UTF16 buffer overflow in bitlk volume key dump.

It is UTF16, so even the terminating character is char16_t.

(Found by gcc sanitizer.)
This commit is contained in:
Milan Broz
2022-04-17 13:45:35 +02:00
parent 99c4c3adbf
commit 2857e10083

View File

@@ -969,7 +969,7 @@ static int bitlk_kdf(struct crypt_device *cd,
if (!recovery) {
/* passphrase: convert to UTF-16 first, then sha256(sha256(pw)) */
utf16Password = crypt_safe_alloc(sizeof(char16_t) * passwordLen + 1);
utf16Password = crypt_safe_alloc(sizeof(char16_t) * (passwordLen + 1));
if (!utf16Password) {
r = -ENOMEM;
goto out;