diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-08-17 02:34:44 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-08-17 02:34:44 +0200 |
commit | 1ebbf81c00fd1f1bd4941bf18a3b3990a77648d2 (patch) | |
tree | 17dd0a9800c0303e6cced1e8a50f75df8b7369cf | |
parent | c2dd57d2087c77c7317e4b802905b68ffd3d15c3 (diff) | |
download | fastd-1ebbf81c00fd1f1bd4941bf18a3b3990a77648d2.tar fastd-1ebbf81c00fd1f1bd4941bf18a3b3990a77648d2.zip |
Use readdir instead of readdir_r
readdir_r can be unsafe for very long filenames.
-rw-r--r-- | src/config.c | 12 |
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; |