@@ -1003,7 +1003,8 @@ bool SdBaseFile::openNext(SdBaseFile *dirFile, uint8_t oflag) {
1003
1003
bool SdBaseFile::isDirLFN (const dir_t * dir) {
1004
1004
if (DIR_IS_LONG_NAME (dir)) {
1005
1005
vfat_t *VFAT = (vfat_t *)dir;
1006
- // Sanity-check the VFAT entry. The first cluster is always set to zero. And the sequence number should be higher than 0
1006
+ // Sanity-check the VFAT entry. The first cluster is always set to zero.
1007
+ // The sequence number should be higher than 0 and lower than maximum allowed by VFAT spec
1007
1008
if ((VFAT->firstClusterLow == 0 ) && WITHIN ((VFAT->sequenceNumber & 0x1F ), 1 , MAX_VFAT_ENTRIES)) return true ;
1008
1009
}
1009
1010
return false ;
@@ -1463,7 +1464,7 @@ int8_t SdBaseFile::readDir(dir_t *dir, char * const longFilename) {
1463
1464
// Sanity-check the VFAT entry. The first cluster is always set to zero. And the sequence number should be higher than 0
1464
1465
if (VFAT->firstClusterLow == 0 ) {
1465
1466
const uint8_t seq = VFAT->sequenceNumber & 0x1F ;
1466
- if (WITHIN (seq, 1 , MAX_VFAT_ENTRIES )) {
1467
+ if (WITHIN (seq, 1 , VFAT_ENTRIES_LIMIT )) {
1467
1468
if (seq == 1 ) {
1468
1469
checksum = VFAT->checksum ;
1469
1470
checksum_error = 0 ;
@@ -1627,7 +1628,7 @@ bool SdBaseFile::remove() {
1627
1628
// Check if the entry has a LFN
1628
1629
bool lastEntry = false ;
1629
1630
// loop back to search for any LFN entries related to this file
1630
- LOOP_S_LE_N (sequenceNumber, 1 , MAX_VFAT_ENTRIES ) {
1631
+ LOOP_S_LE_N (sequenceNumber, 1 , VFAT_ENTRIES_LIMIT ) {
1631
1632
dirIndex_ = (dirIndex_ - 1 ) & 0xF ;
1632
1633
if (dirBlock_ == 0 ) break ;
1633
1634
if (dirIndex_ == 0xF ) dirBlock_--;
0 commit comments