diff options
author | Dave Reisner <dreisner@archlinux.org> | 2014-04-19 13:22:35 -0400 |
---|---|---|
committer | Dave Reisner <dreisner@archlinux.org> | 2014-04-21 09:52:08 -0400 |
commit | 370c860f748d149097710dc7952a64f627db9de7 (patch) | |
tree | 8f5238269d4c3e8622dec4d7d97f1afd775e230e /src/libudev | |
parent | dbb9401dba0bd5157d021e695a47bf52b2d74a2d (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/libudev')
-rw-r--r-- | src/libudev/libudev-monitor.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c index 3f7436b094..0a2ab82a89 100644 --- a/src/libudev/libudev-monitor.c +++ b/src/libudev/libudev-monitor.c @@ -108,15 +108,13 @@ static struct udev_monitor *udev_monitor_new(struct udev *udev) /* we consider udev running when /dev is on devtmpfs */ static bool udev_has_devtmpfs(struct udev *udev) { - struct file_handle *h; + union file_handle_union h = { .handle.handle_bytes = MAX_HANDLE_SZ, }; int mount_id; _cleanup_fclose_ FILE *f = NULL; char line[LINE_MAX], *e; int r; - h = alloca(MAX_HANDLE_SZ); - h->handle_bytes = MAX_HANDLE_SZ; - r = name_to_handle_at(AT_FDCWD, "/dev", h, &mount_id, 0); + r = name_to_handle_at(AT_FDCWD, "/dev", &h.handle, &mount_id, 0); if (r < 0) return false; |