Skip to content

Commit f1cc2d1

Browse files
committed
Packages (OpenBSD): fix counting by ignoring hidden folders
1 parent 1e32a95 commit f1cc2d1

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/detection/packages/packages.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,22 +100,23 @@ uint32_t ffPackagesGetNumElements(const char* dirname, bool isdir)
100100
{
101101
bool ok = false;
102102

103+
if (entry->d_name[0] != '.')
104+
{
103105
#if !defined(__sun) && !defined(__HAIKU__)
104-
if(entry->d_type != DT_UNKNOWN && entry->d_type != DT_LNK)
105-
ok = entry->d_type == (isdir ? DT_DIR : DT_REG);
106-
else
106+
if(entry->d_type != DT_UNKNOWN && entry->d_type != DT_LNK)
107+
ok = entry->d_type == (isdir ? DT_DIR : DT_REG);
108+
else
107109
#endif
108-
{
109-
struct stat stbuf;
110-
if (fstatat(dirfd(dirp), entry->d_name, &stbuf, 0) == 0)
111-
ok = isdir ? S_ISDIR(stbuf.st_mode) : S_ISREG(stbuf.st_mode);
110+
{
111+
struct stat stbuf;
112+
if (fstatat(dirfd(dirp), entry->d_name, &stbuf, 0) == 0)
113+
ok = isdir ? S_ISDIR(stbuf.st_mode) : S_ISREG(stbuf.st_mode);
114+
}
112115
}
113116

114117
if(ok) ++num_elements;
115118
}
116119

117-
if(isdir && num_elements >= 2)
118-
num_elements -= 2; // accounting for . and ..
119120

120121
return num_elements;
121122
}

0 commit comments

Comments
 (0)