fix: panic in reading PCR values

Fix panic in reading PCR values.

Fixes: #13110

Signed-off-by: Noel Georgi <git@frezbo.dev>
This commit is contained in:
Noel Georgi 2026-04-14 14:33:08 +05:30
parent 6a3ab87c54
commit c81aa125c8
No known key found for this signature in database
GPG Key ID: 21A9F444075C9E36

View File

@ -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.