@@ -7340,9 +7340,9 @@ static TPM_RC FwCmd_StartAuthSession(FWTPM_CTX* ctx, TPM2_Packet* cmd,
73407340 }
73417341 }
73427342 if (bindAuth .size > sizeof (bindAuth .buffer )) {
7343- bindAuth . size = ( UINT16 ) sizeof ( bindAuth . buffer ) ;
7343+ rc = TPM_RC_FAILURE ;
73447344 }
7345- if (bindAuth .size > 0 ) {
7345+ if (rc == 0 && bindAuth .size > 0 ) {
73467346 if (keyInSz + bindAuth .size <= (int )sizeof (keyIn )) {
73477347 XMEMCPY (keyIn + keyInSz , bindAuth .buffer , bindAuth .size );
73487348 keyInSz += bindAuth .size ;
@@ -11115,30 +11115,41 @@ static TPM_RC FwCmd_Quote(FWTPM_CTX* ctx, TPM2_Packet* cmd,
1111511115 rc = TPM_RC_FAILURE ;
1111611116 }
1111711117 if (rc == 0 ) {
11118- for (s = 0 ; s < numSel ; s ++ ) {
11118+ for (s = 0 ; s < numSel && rc == 0 ; s ++ ) {
1111911119 int bank = FwGetPcrBankIndex (selections [s ].hashAlg );
1112011120 int bankDSz = TPM2_GetHashDigestSize (
1112111121 selections [s ].hashAlg );
1112211122 UINT32 j ;
1112311123 if (bank < 0 || bankDSz == 0 )
1112411124 continue ;
11125- for (j = 0 ; j < selections [s ].sizeOfSelect ; j ++ ) {
11125+ for (j = 0 ; j < selections [s ].sizeOfSelect &&
11126+ rc == 0 ; j ++ ) {
1112611127 int pcr ;
1112711128 for (pcr = 0 ; pcr < 8 ; pcr ++ ) {
1112811129 if (selections [s ].pcrSelect [j ] & (1 << pcr )) {
1112911130 int pcrIdx = j * 8 + pcr ;
1113011131 if (pcrIdx < IMPLEMENTATION_PCR ) {
11131- wc_HashUpdate (hashCtx , wcH ,
11132- ctx -> pcrDigest [pcrIdx ][bank ],
11133- bankDSz );
11132+ if (wc_HashUpdate (hashCtx , wcH ,
11133+ ctx -> pcrDigest [pcrIdx ][bank ],
11134+ bankDSz ) != 0 ) {
11135+ rc = TPM_RC_FAILURE ;
11136+ break ;
11137+ }
1113411138 }
1113511139 }
1113611140 }
1113711141 }
1113811142 }
11139- wc_HashFinal (hashCtx , wcH , pcrDigestBuf );
11143+ if (rc == 0 ) {
11144+ if (wc_HashFinal (hashCtx , wcH ,
11145+ pcrDigestBuf ) != 0 ) {
11146+ rc = TPM_RC_FAILURE ;
11147+ }
11148+ else {
11149+ pcrDigestSz = dSz ;
11150+ }
11151+ }
1114011152 wc_HashFree (hashCtx , wcH );
11141- pcrDigestSz = dSz ;
1114211153 }
1114311154 }
1114411155 TPM2_Packet_AppendU16 (& attestPkt , (UINT16 )pcrDigestSz );
0 commit comments