From d5cd09ebf769ed628dabf383a54defdb68d23e25 Mon Sep 17 00:00:00 2001 From: Christopher Williams Date: Tue, 24 Jul 2018 17:46:45 -0700 Subject: [PATCH] R0.13b patch 1 May 23, 2018 Reading a directory gets infinite loop. Successive f_readdir() calls would not detect the end of directory if the directory was filled up and the last entry is not empty. This problem was reported at the User Forum. --- source/ff.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/ff.c b/source/ff.c index a114c6b..c57a320 100644 --- a/source/ff.c +++ b/source/ff.c @@ -1728,7 +1728,8 @@ static FRESULT dir_next ( /* FR_OK(0):succeeded, FR_NO_FILE:End of table, FR_DEN ofs = dp->dptr + SZDIRE; /* Next entry */ - if (dp->sect == 0 || ofs >= (DWORD)((FF_FS_EXFAT && fs->fs_type == FS_EXFAT) ? MAX_DIR_EX : MAX_DIR)) return FR_NO_FILE; /* Report EOT when offset has reached max value */ + if (ofs >= (DWORD)((FF_FS_EXFAT && fs->fs_type == FS_EXFAT) ? MAX_DIR_EX : MAX_DIR)) dp->sect = 0; /* Disable it if the offset reached the max value */ + if (dp->sect == 0) return FR_NO_FILE; /* Report EOT if it has been disabled */ if (ofs % SS(fs) == 0) { /* Sector changed? */ dp->sect++; /* Next sector */