summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-08-17 02:34:44 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-08-17 02:34:44 +0200
commit1ebbf81c00fd1f1bd4941bf18a3b3990a77648d2 (patch)
tree17dd0a9800c0303e6cced1e8a50f75df8b7369cf /src
parentc2dd57d2087c77c7317e4b802905b68ffd3d15c3 (diff)
downloadfastd-1ebbf81c00fd1f1bd4941bf18a3b3990a77648d2.tar
fastd-1ebbf81c00fd1f1bd4941bf18a3b3990a77648d2.zip
Use readdir instead of readdir_r
readdir_r can be unsafe for very long filenames.
Diffstat (limited to 'src')
-rw-r--r--src/config.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/config.c b/src/config.c
index 8a417e9..672c0a7 100644
--- a/src/config.c
+++ b/src/config.c
@@ -324,17 +324,15 @@ static void read_peer_dir(fastd_context_t *ctx, fastd_config_t *conf, const char
if (dirh) {
while (true) {
- struct dirent entry, *result;
- int ret;
+ errno = 0;
+ struct dirent *result = readdir(dirh);
+ if (!result) {
+ if (errno)
+ pr_error_errno(ctx, "readdir");
- ret = readdir_r(dirh, &entry, &result);
- if (ret) {
- pr_error(ctx, "readdir_r: %s", strerror(ret));
break;
}
- if (!result)
- break;
if (result->d_name[0] == '.')
continue;