Fix NULL key_description bug in luks2-keyring token.

json-c parser transforms NULL pointer into special '(null)' string.
While being technically correct it hides the fact user passed NULL
pointer in crypt_token_params_luks2_keyring structure. This bug
could be trigerred by calling crypt_token_luks2_keyring_set().
This commit is contained in:
Ondrej Kozina
2022-09-01 15:21:41 +02:00
parent 94e8a7ca96
commit eac02f5605
2 changed files with 3 additions and 2 deletions

View File

@@ -1744,7 +1744,7 @@ static void TokenActivationByKeyring(void)
.key_description = KEY_DESC_TEST0
}, params2 = {
.key_description = KEY_DESC_TEST1
};
}, params_invalid = {};
uint64_t r_payload_offset;
if (!t_dm_crypt_keyring_support()) {
@@ -1763,6 +1763,7 @@ static void TokenActivationByKeyring(void)
OK_(set_fast_pbkdf(cd));
OK_(crypt_format(cd, CRYPT_LUKS2, cipher, cipher_mode, NULL, NULL, 32, NULL));
EQ_(crypt_keyslot_add_by_volume_key(cd, 0, NULL, 32, PASSPHRASE, strlen(PASSPHRASE)), 0);
FAIL_(crypt_token_luks2_keyring_set(cd, CRYPT_ANY_TOKEN, &params_invalid), "Invalid key description property.");
EQ_(crypt_token_luks2_keyring_set(cd, 3, &params), 3);
EQ_(crypt_token_assign_keyslot(cd, 3, 0), 3);
CRYPT_FREE(cd);