diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-09-19 22:21:09 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-09-19 22:21:09 +0200 |
commit | 7d5e9c0f60cddf01ec803012cbdc02d2f55b78c1 (patch) | |
tree | ecb5dc336ce9e0ecf6d5e3b6757b0a10f7f1e692 /src/journal | |
parent | 57f3067825d9361d7487f272bfaff3b36c684c62 (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/journal')
-rw-r--r-- | src/journal/journal-vacuum.c | 5 | ||||
-rw-r--r-- | src/journal/journald.c | 5 | ||||
-rw-r--r-- | src/journal/sd-journal.c | 10 |
3 files changed, 12 insertions, 8 deletions
diff --git a/src/journal/journal-vacuum.c b/src/journal/journal-vacuum.c index c890146537..ac16bdfcfd 100644 --- a/src/journal/journal-vacuum.c +++ b/src/journal/journal-vacuum.c @@ -86,7 +86,8 @@ int journal_directory_vacuum(const char *directory, uint64_t max_use, uint64_t m for (;;) { int k; - struct dirent buf, *de; + struct dirent *de; + union dirent_storage buf; size_t q; struct stat st; char *p; @@ -94,7 +95,7 @@ int journal_directory_vacuum(const char *directory, uint64_t max_use, uint64_t m sd_id128_t seqnum_id; bool have_seqnum; - k = readdir_r(d, &buf, &de); + k = readdir_r(d, &buf.de, &de); if (k != 0) { r = -k; goto finish; diff --git a/src/journal/journald.c b/src/journal/journald.c index 74c80f5a08..164e1087d1 100644 --- a/src/journal/journald.c +++ b/src/journal/journald.c @@ -141,9 +141,10 @@ static uint64_t available_space(Server *s) { for (;;) { struct stat st; - 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) break; diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index 2fa81727e0..acde84fe2d 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -1256,9 +1256,10 @@ static int add_directory(sd_journal *j, const char *prefix, const char *dirname) } 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 || !de) break; @@ -1334,10 +1335,11 @@ static int add_root_directory(sd_journal *j, const char *p) { } for (;;) { - struct dirent buf, *de; + struct dirent *de; + union dirent_storage buf; sd_id128_t id; - r = readdir_r(d, &buf, &de); + r = readdir_r(d, &buf.de, &de); if (r != 0 || !de) break; |