cryptenroll: don't return slot 0 when we have no policy to search for

If the policy hash is empty we shouldn't return "0" from
search_policy_hash(), because that is understood as slot index 0, but
that's unlikely to match the policy.

Hence, return -ENOENT instead, indicating that we can't find a matching
slot.
This commit is contained in:
Lennart Poettering 2024-08-29 12:54:40 +02:00
parent 549c1a99d4
commit 41bcb93087

View File

@ -26,7 +26,7 @@ static int search_policy_hash(
assert(iovec_is_valid(hash));
if (!iovec_is_set(hash))
return 0;
return -ENOENT;
for (int token = 0; token < sym_crypt_token_max(CRYPT_LUKS2); token++) {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;