cryptsetup: do not assert when unsealing token without salt

Salt was added in v253. We are not checking whether it was actually found
(non-zero size), so when an old tpm+pin enrollment is opened things go boom.
For good measure, check both the buffer and the size in both places.

Assertion 'saltlen > 0' failed at src/shared/tpm2-util.c:2490, function tpm2_util_pbkdf2_hmac_sha256(). Aborting.
This commit is contained in:
Luca Boccassi
2023-02-15 18:01:28 +00:00
committed by Luca Boccassi
parent c126c8ac81
commit 504d0acf61
3 changed files with 6 additions and 2 deletions
+1
View File
@@ -2487,6 +2487,7 @@ int tpm2_util_pbkdf2_hmac_sha256(const void *pass,
*/
static const uint8_t block_cnt[] = { 0, 0, 0, 1 };
assert (salt);
assert (saltlen > 0);
assert (saltlen <= (SIZE_MAX - sizeof(block_cnt)));
assert (passlen > 0);