From 79ca134f7fa859a739f68d9ee92ac92c7106bcee Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Thu, 26 Jul 2012 00:07:27 -0500 Subject: [PATCH] pkg: call stat(2) in scan function --- pkg.c | 5 +++++ stdinc.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/pkg.c b/pkg.c index 9c45301..b5498e8 100644 --- a/pkg.c +++ b/pkg.c @@ -289,11 +289,16 @@ pkg_scan_dir(const char *path, pkg_iteration_func_t func) static char filebuf[PKG_BUFSIZE]; pkg_t *pkg; FILE *f; + struct stat st; strlcpy(filebuf, path, sizeof filebuf); strlcat(filebuf, "/", sizeof filebuf); strlcat(filebuf, dirent->d_name, sizeof filebuf); + stat(filebuf, &st); + if (!(S_ISREG(st.st_mode))) + continue; + f = fopen(filebuf, "r"); if (f == NULL) continue; diff --git a/stdinc.h b/stdinc.h index cc35e57..f8a7537 100644 --- a/stdinc.h +++ b/stdinc.h @@ -24,6 +24,9 @@ #include #include #include +#include +#include +#include #ifdef _WIN32 # define WIN32_LEAN_AND_MEAN