@@ -4367,9 +4367,16 @@ static int wp11_Token_Store(WP11_Token* token, int tokenId)
43674367 wp11_storage_close (storage );
43684368
43694369 object = token -> object ;
4370- for (i = token -> objCnt - 1 ; ( ret == 0 ) && ( i >= 0 ) ; i -- ) {
4370+ for (i = token -> objCnt - 1 ; i >= 0 ; i -- ) {
43714371 /* Write the objects. */
43724372 ret = wp11_Object_Store (object , tokenId , i );
4373+ if (ret != 0 ) {
4374+ #if DEBUG_WOLFPKCS11
4375+ printf ("Failed to store object %d, token %d, ret: %d\n" ,
4376+ i , tokenId , ret );
4377+ #endif
4378+ break ;
4379+ }
43734380 object = object -> next ;
43744381 }
43754382 }
@@ -4637,8 +4644,15 @@ void WP11_Library_Final(void)
46374644 if (cnt == 0 ) {
46384645#ifndef WOLFPKCS11_NO_STORE
46394646 /* Store the slots. */
4640- for (i = 0 ; i < slotCnt ; i ++ )
4641- wp11_Slot_Store (& slotList [i ], i + 1 );
4647+ for (i = 0 ; i < slotCnt ; i ++ ) {
4648+ int ret = wp11_Slot_Store (& slotList [i ], i + 1 );
4649+ #if DEBUG_WOLFPKCS11
4650+ if (ret != 0 ) {
4651+ printf ("Failed to store slot %d, ret: %d\n" , i + 1 , ret );
4652+ }
4653+ #endif
4654+ (void )ret ; /* store failure cannot be returned, so log and ignore */
4655+ }
46424656#endif
46434657 /* Cleanup the slots. */
46444658 for (i = 0 ; i < slotCnt ; i ++ )
@@ -6179,7 +6193,7 @@ int WP11_Session_AddObject(WP11_Session* session, int onToken,
61796193 }
61806194 #ifndef WOLFPKCS11_NO_STORE
61816195 if (ret == 0 ) {
6182- wp11_Slot_Store (session -> slot , (int )session -> slotId );
6196+ ret = wp11_Slot_Store (session -> slot , (int )session -> slotId );
61836197 }
61846198 #endif
61856199 }
@@ -6246,8 +6260,16 @@ void WP11_Session_RemoveObject(WP11_Session* session, WP11_Object* object)
62466260 }
62476261 if (object -> onToken ) {
62486262#ifndef WOLFPKCS11_NO_STORE
6263+ int ret ;
62496264 wp11_Object_Unstore (object , (int )session -> slotId , id );
6250- wp11_Slot_Store (session -> slot , (int )session -> slotId );
6265+ ret = wp11_Slot_Store (session -> slot , (int )session -> slotId );
6266+ #if DEBUG_WOLFPKCS11
6267+ if (ret != 0 ) {
6268+ printf ("Failed to store slot %d, ret: %d\n" ,
6269+ (int )session -> slotId , ret );
6270+ }
6271+ #endif
6272+ (void )ret ; /* store failure cannot be returned, so log and ignore */
62516273#endif
62526274 WP11_Lock_UnlockRW (object -> lock );
62536275 }
0 commit comments