File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -284,10 +284,10 @@ TPM_RC TPM2_CountAuthSessions(TPM2_CTX *ctx, int *authSessionCount)
284284{
285285 int sessionCount , sessionHandle ;
286286
287- if (ctx == NULL || ctx -> authCmd == NULL || authSessionCount == NULL )
287+ if (ctx == NULL || ctx -> authCmd == NULL || authSessionCount == NULL )
288288 return TPM_RC_FAILURE ;
289289
290- for (sessionCount = 0 ; sessionCount < MAX_SESSION_NUM ; sessionCount ++ ) {
290+ for (sessionCount = 0 ; sessionCount < MAX_SESSION_NUM ; sessionCount ++ ) {
291291 sessionHandle = ctx -> authCmd [sessionCount ].sessionHandle ;
292292 /* According to the TCG Spec, Part 1, Chapter 15.4
293293 * Session Handles have most significant octet at
@@ -296,11 +296,11 @@ TPM_RC TPM2_CountAuthSessions(TPM2_CTX *ctx, int *authSessionCount)
296296 * Password sessions use predefined value of TPM_RS_PW
297297 * Trial sessions are not of interest
298298 */
299- if (sessionHandle != TPM_RS_PW ) {
299+ if (sessionHandle != TPM_RS_PW ) {
300300 /* Not a password session, mask the most significant octet(MSO) */
301301 sessionHandle &= 0xFF000000 ;
302302 /* Check MSO for an HMAC or Policy session, otherwise invalid */
303- if ( sessionHandle ^ 0x02000000 && sessionHandle ^ 0x03000000 )
303+ if (( sessionHandle ^ 0x02000000 ) && ( sessionHandle ^ 0x03000000 ) )
304304 break ;
305305 }
306306 }
Original file line number Diff line number Diff line change @@ -315,21 +315,26 @@ void TPM2_Packet_PlaceU32(TPM2_Packet* packet, int markSz)
315315 }
316316}
317317
318+ /* TODO: We should add a return code here */
318319void TPM2_Packet_AppendAuth (TPM2_Packet * packet , TPM2_CTX * ctx )
319320{
320321 int tmpSz = 0 ;
321322 int i , authCount ;
322323 TPMS_AUTH_COMMAND * auth ;
323324
324- if (ctx == NULL ) {
325+ if (ctx == NULL )
325326 return ;
326- }
327327
328328 auth = ctx -> authCmd ;
329+ if (auth == NULL )
330+ return ;
329331
330332 if (TPM2_CountAuthSessions (ctx , & authCount ) != TPM_RC_SUCCESS )
331333 return ;
332334
335+ if (authCount > MAX_SESSION_NUM )
336+ return ;
337+
333338 TPM2_Packet_MarkU32 (packet , & tmpSz );
334339 for (i = 0 ; i < authCount ; i ++ ) {
335340 /* make sure continueSession is set for TPM_RS_PW */
You can’t perform that action at this time.
0 commit comments