Guard fwTPM public name computation on buffer allocation success

pull/605/head
Aidan Garske 2026-09-11 09:17:49 -07:00
parent 4ff1972737
commit b571dfba5f
1 changed files with 12 additions and 13 deletions

View File

@ -192,21 +192,20 @@ int FwComputePublicName(TPMT_PUBLIC* pub, TPM2B_NAME* name)
int digestSz;
FWTPM_ALLOC_BUF(pubBuf, FWTPM_MAX_PUB_BUF);
if (rc != 0) {
return rc;
}
/* Marshal public area into temp buffer */
tmpPkt.buf = pubBuf;
tmpPkt.pos = 0;
tmpPkt.size = (int)FWTPM_MAX_PUB_BUF;
TPM2_Packet_AppendPublicArea(&tmpPkt, pub);
pubSz = tmpPkt.pos;
if (rc == 0) {
/* Marshal public area into temp buffer */
tmpPkt.buf = pubBuf;
tmpPkt.pos = 0;
tmpPkt.size = (int)FWTPM_MAX_PUB_BUF;
TPM2_Packet_AppendPublicArea(&tmpPkt, pub);
pubSz = tmpPkt.pos;
wcHash = FwGetWcHashType(pub->nameAlg);
digestSz = TPM2_GetHashDigestSize(pub->nameAlg);
if (wcHash == WC_HASH_TYPE_NONE || digestSz == 0) {
rc = TPM_RC_HASH;
wcHash = FwGetWcHashType(pub->nameAlg);
digestSz = TPM2_GetHashDigestSize(pub->nameAlg);
if (wcHash == WC_HASH_TYPE_NONE || digestSz == 0) {
rc = TPM_RC_HASH;
}
}
if (rc == 0) {