summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-09-19 22:21:09 +0200
committerLennart Poettering <lennart@poettering.net>2012-09-19 22:21:09 +0200
commit7d5e9c0f60cddf01ec803012cbdc02d2f55b78c1 (patch)
treeecb5dc336ce9e0ecf6d5e3b6757b0a10f7f1e692 /src/shared/util.c
parent57f3067825d9361d7487f272bfaff3b36c684c62 (diff)
util: define union dirent_storage and make use of it everywhere
Make sure to allocate enough space for readdir_r(). https://bugzilla.redhat.com/show_bug.cgi?id=858754
Diffstat (limited to 'src/shared/util.c')
-rw-r--r--src/shared/util.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index 69c9437db8..b48bad4c46 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -2956,9 +2956,10 @@ int dir_is_empty(const char *path) {
return -errno;
for (;;) {
- struct dirent buf, *de;
+ struct dirent *de;
+ union dirent_storage buf;
- r = readdir_r(d, &buf, &de);
+ r = readdir_r(d, &buf.de, &de);
if (r > 0)
return -r;
@@ -3260,12 +3261,13 @@ int rm_rf_children_dangerous(int fd, bool only_dirs, bool honour_sticky, struct
}
for (;;) {
- struct dirent buf, *de;
+ struct dirent *de;
+ union dirent_storage buf;
bool is_dir, keep_around;
struct stat st;
int r;
- r = readdir_r(d, &buf, &de);
+ r = readdir_r(d, &buf.de, &de);
if (r != 0 && ret == 0) {
ret = -r;
break;
@@ -4942,10 +4944,11 @@ int get_files_in_directory(const char *path, char ***list) {
return -errno;
for (;;) {
- struct dirent buffer, *de;
+ struct dirent *de;
+ union dirent_storage buf;
int k;
- k = readdir_r(d, &buffer, &de);
+ k = readdir_r(d, &buf.de, &de);
if (k != 0) {
r = -k;
goto finish;