summaryrefslogtreecommitdiff
path: root/src/tmpfiles/tmpfiles.c
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2014-04-19 13:22:35 -0400
committerDave Reisner <dreisner@archlinux.org>2014-04-21 09:52:08 -0400
commit370c860f748d149097710dc7952a64f627db9de7 (patch)
tree8f5238269d4c3e8622dec4d7d97f1afd775e230e /src/tmpfiles/tmpfiles.c
parentdbb9401dba0bd5157d021e695a47bf52b2d74a2d (diff)
implement a union to pad out file_handle
Cases where name_to_handle_at is used allocated the full struct to be MAX_HANDLE_SZ, and assigned this size to handle_bytes. This is wrong since handle_bytes should describe the length of the flexible array member and not the whole struct. Define a union type which includes sufficient padding to allow assignment of MAX_HANDLE_SZ to be correct.
Diffstat (limited to 'src/tmpfiles/tmpfiles.c')
-rw-r--r--src/tmpfiles/tmpfiles.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 33e7cbc05d..04b472da97 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -217,19 +217,16 @@ static bool unix_socket_alive(const char *fn) {
}
static int dir_is_mount_point(DIR *d, const char *subdir) {
- struct file_handle *h;
+ union file_handle_union h = { .handle.handle_bytes = MAX_HANDLE_SZ };
int mount_id_parent, mount_id;
int r_p, r;
- h = alloca(MAX_HANDLE_SZ);
-
- h->handle_bytes = MAX_HANDLE_SZ;
- r_p = name_to_handle_at(dirfd(d), ".", h, &mount_id_parent, 0);
+ r_p = name_to_handle_at(dirfd(d), ".", &h.handle, &mount_id_parent, 0);
if (r_p < 0)
r_p = -errno;
- h->handle_bytes = MAX_HANDLE_SZ;
- r = name_to_handle_at(dirfd(d), subdir, h, &mount_id, 0);
+ h.handle.handle_bytes = MAX_HANDLE_SZ;
+ r = name_to_handle_at(dirfd(d), subdir, &h.handle, &mount_id, 0);
if (r < 0)
r = -errno;