From: Dan Streetman Date: Mon, 21 Aug 2023 21:37:40 +0000 (-0400) Subject: tpm2: check pcr value hash != 0 before looking up hash algorithm name X-Git-Tag: v255-rc1~630^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e757259c3f491841a6c5aa853f2cfce41e95b2e;p=thirdparty%2Fsystemd.git tpm2: check pcr value hash != 0 before looking up hash algorithm name --- diff --git a/src/shared/tpm2-util.c b/src/shared/tpm2-util.c index db51d46bd46..8ba363fdccd 100644 --- a/src/shared/tpm2-util.c +++ b/src/shared/tpm2-util.c @@ -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);