@@ -481,7 +481,6 @@ void WriteFileSettings(uint8_t AppSlot, uint8_t FileIndex, DESFireFileTypeSettin
481
481
}
482
482
SIZET fileTypeSettingsBlockId = GetAppProperty (DESFIRE_APP_FILES_PTR_BLOCK_ID , AppSlot );
483
483
SIZET fileTypeSettingsAddresses [DESFIRE_MAX_FILES ];
484
- // TODO: ???
485
484
ReadBlockBytes (fileTypeSettingsAddresses , fileTypeSettingsBlockId , 2 * DESFIRE_MAX_FILES );
486
485
WriteBlockBytes (FileSettings , fileTypeSettingsAddresses [FileIndex ], sizeof (DESFireFileTypeSettings ));
487
486
memcpy (& (SelectedFile .File ), FileSettings , sizeof (DESFireFileTypeSettings ));
@@ -494,10 +493,11 @@ void WriteFileSettings(uint8_t AppSlot, uint8_t FileIndex, DESFireFileTypeSettin
494
493
uint8_t LookupAppSlot (const DESFireAidType Aid ) {
495
494
uint8_t Slot ;
496
495
for (Slot = 0 ; Slot < DESFIRE_MAX_SLOTS ; ++ Slot ) {
497
- if (!memcmp (AppDir .AppIds [Slot ], Aid , DESFIRE_AID_SIZE ))
498
- break ;
496
+ if (!memcmp (AppDir .AppIds [Slot ], Aid , DESFIRE_AID_SIZE )) {
497
+ return Slot ;
498
+ }
499
499
}
500
- return Slot ;
500
+ return DESFIRE_MAX_SLOTS ;
501
501
}
502
502
503
503
void SelectAppBySlot (uint8_t AppSlot ) {
@@ -578,7 +578,7 @@ uint16_t CreateApp(const DESFireAidType Aid, uint8_t KeyCount, uint8_t KeySettin
578
578
}
579
579
/* Update the next free slot */
580
580
for (FreeSlot = 1 ; FreeSlot < DESFIRE_MAX_SLOTS ; ++ FreeSlot ) {
581
- if ((AppDir .AppIds [FreeSlot ][0 ] | AppDir .AppIds [FreeSlot ][1 ] | AppDir .AppIds [FreeSlot ][2 ]) == 0 )
581
+ if (FreeSlot != Slot && (AppDir .AppIds [FreeSlot ][0 ] | AppDir .AppIds [FreeSlot ][1 ] | AppDir .AppIds [FreeSlot ][2 ]) == 0 )
582
582
break ;
583
583
}
584
584
@@ -603,7 +603,7 @@ uint16_t CreateApp(const DESFireAidType Aid, uint8_t KeyCount, uint8_t KeySettin
603
603
} else {
604
604
BYTE keySettings [DESFIRE_MAX_KEYS ];
605
605
memset (keySettings , KeySettings , DESFIRE_MAX_KEYS );
606
- keySettings [0 ] = KeySettings ; // NEEDED ???
606
+ keySettings [0 ] = KeySettings ;
607
607
WriteBlockBytes (keySettings , appCacheData .KeySettings , DESFIRE_MAX_KEYS );
608
608
}
609
609
appCacheData .FileNumbersArrayMap = AllocateBlocks (APP_CACHE_FILE_NUMBERS_HASHMAP_BLOCK_SIZE );
@@ -710,8 +710,7 @@ uint16_t DeleteApp(const DESFireAidType Aid) {
710
710
}
711
711
712
712
void GetApplicationIdsSetup (void ) {
713
- /* Skip the PICC application */
714
- TransferState .GetApplicationIds .NextIndex = 1 ;
713
+ TransferState .GetApplicationIds .NextIndex = 0 ;
715
714
}
716
715
717
716
TransferStatus GetApplicationIdsTransfer (uint8_t * Buffer ) {
@@ -724,7 +723,7 @@ TransferStatus GetApplicationIdsTransfer(uint8_t *Buffer) {
724
723
continue ;
725
724
}
726
725
/* If it won't fit -- remember and return */
727
- if (Status .BytesProcessed >= TERMINAL_BUFFER_SIZE ) {
726
+ if (Status .BytesProcessed >= TERMINAL_BUFFER_SIZE - 20 ) {
728
727
TransferState .GetApplicationIds .NextIndex = EntryIndex ;
729
728
Status .IsComplete = false;
730
729
return Status ;
0 commit comments