From c81aa125c85d3886c5b9bb4d7f77ec2def104f21 Mon Sep 17 00:00:00 2001 From: Noel Georgi Date: Tue, 14 Apr 2026 14:33:08 +0530 Subject: [PATCH] fix: panic in reading PCR values Fix panic in reading PCR values. Fixes: #13110 Signed-off-by: Noel Georgi --- internal/pkg/secureboot/tpm2/pcr.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/pkg/secureboot/tpm2/pcr.go b/internal/pkg/secureboot/tpm2/pcr.go index d4cfe709e..a47f12f6f 100644 --- a/internal/pkg/secureboot/tpm2/pcr.go +++ b/internal/pkg/secureboot/tpm2/pcr.go @@ -60,7 +60,11 @@ func ReadPCR(t transport.TPM, pcr int) ([]byte, error) { return nil, fmt.Errorf("failed to read PCR: %w", err) } - return pcrValue.PCRValues.Digests[0].Buffer, nil + if pcrValue != nil && len(pcrValue.PCRValues.Digests) > 0 { + return pcrValue.PCRValues.Digests[0].Buffer, nil + } + + return nil, fmt.Errorf("PCR value for PCR %d is not available", pcr) } // PCRExtend hashes the input and extends the PCR with the hash.