Global: fix other possible bugs where enumerating directories without ignoring . and ..

This commit is contained in:
李通洲
2023-01-09 10:45:51 +08:00
parent 0b12e73eef
commit 0fd63084dc
3 changed files with 8 additions and 0 deletions
+3
View File
@@ -99,6 +99,9 @@ const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results) {
struct dirent* entry;
while((entry = readdir(dirp)) != NULL)
{
if(strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
continue;
ffStrbufAppendS(&baseDir, entry->d_name);
parseBattery(&baseDir, results);
ffStrbufSubstrBefore(&baseDir, baseDirLength);
@@ -73,6 +73,9 @@ static void parseDRM(FFDisplayServerResult* result)
struct dirent* entry;
while((entry = readdir(dirp)) != NULL)
{
if(strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
continue;
ffStrbufAppendS(&drmDir, entry->d_name);
ffStrbufAppendS(&drmDir, "/modes");
+2
View File
@@ -309,6 +309,8 @@ static void getPackageCountsBedrock(const FFinstance* instance, FFstrbuf* baseDi
{
if(entry->d_type != DT_DIR)
continue;
if(strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
continue;
ffStrbufAppendS(baseDir, entry->d_name);
getPackageCounts(instance, baseDir, packageCounts);