Guard tainted PCR select copy in fwTPM PCR_PROPERTIES test (Coverity CID 911493)

pull/558/head
aidan garske 2026-07-22 10:33:35 -07:00
parent 7d02b58e4c
commit e79d060f4d
1 changed files with 2 additions and 0 deletions

View File

@ -8558,6 +8558,7 @@ static void test_fwtpm_pcr_properties_capability(void)
tag = GetU32BE(gRsp + p); p += 4;
wireSz = gRsp[p]; p += 1;
selSz = (wireSz > 8) ? 8 : wireSz;
AssertTrue(selSz > 0); /* select bytes present; keeps p inside gRsp */
AssertTrue(p + selSz <= rspSize);
if (tag == TPM_PT_PCR_RESET_L0) {
memcpy(resetL0, gRsp + p, selSz); gotResetL0 = 1;
@ -8571,6 +8572,7 @@ static void test_fwtpm_pcr_properties_capability(void)
else if (tag == TPM_PT_PCR_DRTM_RESET) {
memcpy(drtm, gRsp + p, selSz); gotDrtm = 1;
}
AssertTrue(p + wireSz <= rspSize); /* full record present on the wire */
p += wireSz; /* advance past the select bytes */
}