]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tpm2: check pcr value hash != 0 before looking up hash algorithm name
authorDan Streetman <ddstreet@ieee.org>
Mon, 21 Aug 2023 21:37:40 +0000 (17:37 -0400)
committerDan Streetman <ddstreet@ieee.org>
Thu, 24 Aug 2023 16:33:26 +0000 (12:33 -0400)
src/shared/tpm2-util.c

index db51d46bd4605aef65399eda6f44660c86d15984..8ba363fdccdcf56f7f9fe702211765f97b3bbbb2 100644 (file)
@@ -1763,7 +1763,7 @@ char *tpm2_pcr_value_to_string(const Tpm2PCRValue *pcr_value) {
         if (asprintf(&index, "%u", pcr_value->index) < 0)
                 return NULL;
 
-        const char *hash = tpm2_hash_alg_to_string(pcr_value->hash);
+        const char *hash = pcr_value->hash > 0 ? tpm2_hash_alg_to_string(pcr_value->hash) : NULL;
 
         if (hash && pcr_value->value.size > 0) {
                 value = hexmem(pcr_value->value.buffer, pcr_value->value.size);