libseckey: Fix length check of SPKI

Field spki_size is defined as size_t, so it can never be negative.
Before the check, sk_ep11_valid_ep11_blob() ensures that hdr->len is
never greater than key_token_length, so the subtraction can never
overflow the result, but it still can be zero.

Assisted-by: IBM Bob:2.0.0
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Ingo Franzki
2026-06-30 15:14:33 +02:00
committed by Jan Höppner
parent 634095aa24
commit c006800bd5

View File

@@ -561,7 +561,7 @@ int SK_EP11_get_key_type(const unsigned char *key_token,
return -EINVAL;
spki_size = key_token_length - hdr->len;
if (spki_size <= 0)
if (spki_size == 0)
return -EINVAL;
rc = sk_ep11_parse_spki(key_token + hdr->len, spki_size,
@@ -1381,7 +1381,7 @@ int SK_EP11_get_public_from_secure_key(const unsigned char *key_token,
return -EINVAL;
spki_size = key_token_length - hdr->len;
if (spki_size <= 0)
if (spki_size == 0)
return -EINVAL;
rc = sk_ep11_parse_spki(key_token + hdr->len, spki_size,