tpm2: check pcr value hash != 0 before looking up hash algorithm name

This commit is contained in:
Dan Streetman
2023-08-24 12:33:26 -04:00
parent 495f2bf57c
commit 8e757259c3
+1 -1
View 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);