summaryrefslogtreecommitdiff
path: root/src/shared/install.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/install.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/install.c')
-rw-r--r--src/shared/install.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/shared/install.c b/src/shared/install.c
index f30bf8317b..a99c757ea8 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -201,7 +201,6 @@ static int remove_marked_symlinks_fd(
int r = 0;
DIR *d;
- struct dirent buffer, *de;
assert(remove_symlinks_to);
assert(fd >= 0);
@@ -218,9 +217,11 @@ static int remove_marked_symlinks_fd(
rewinddir(d);
for (;;) {
+ 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 = -errno;
break;
@@ -375,7 +376,6 @@ static int find_symlinks_fd(
int r = 0;
DIR *d;
- struct dirent buffer, *de;
assert(name);
assert(fd >= 0);
@@ -391,8 +391,10 @@ static int find_symlinks_fd(
for (;;) {
int k;
+ struct dirent *de;
+ union dirent_storage buf;
- k = readdir_r(d, &buffer, &de);
+ k = readdir_r(d, &buf.de, &de);
if (k != 0) {
r = -errno;
break;
@@ -1906,7 +1908,6 @@ int unit_file_get_list(
return r;
STRV_FOREACH(i, paths.unit_path) {
- struct dirent buffer, *de;
const char *units_dir;
free(buf);
@@ -1934,9 +1935,11 @@ int unit_file_get_list(
}
for (;;) {
+ struct dirent *de;
+ union dirent_storage buffer;
UnitFileList *f;
- r = readdir_r(d, &buffer, &de);
+ r = readdir_r(d, &buffer.de, &de);
if (r != 0) {
r = -r;
goto finish;