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/readahead | |
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/readahead')
-rw-r--r-- | src/readahead/readahead-common.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/readahead/readahead-common.c b/src/readahead/readahead-common.c index 5ffa88b78a..49679fc834 100644 --- a/src/readahead/readahead-common.c +++ b/src/readahead/readahead-common.c @@ -75,7 +75,7 @@ int fs_on_ssd(const char *p) { if (major(st.st_dev) == 0) { _cleanup_fclose_ FILE *f = NULL; int mount_id; - struct file_handle *h; + union file_handle_union h = { .handle.handle_bytes = MAX_HANDLE_SZ, }; /* Might be btrfs, which exposes "ssd" as mount flag if it is on ssd. * @@ -83,9 +83,7 @@ int fs_on_ssd(const char *p) { * and then lookup the mount ID in mountinfo to find * the mount options. */ - h = alloca(MAX_HANDLE_SZ); - h->handle_bytes = MAX_HANDLE_SZ; - r = name_to_handle_at(AT_FDCWD, p, h, &mount_id, AT_SYMLINK_FOLLOW); + r = name_to_handle_at(AT_FDCWD, p, &h.handle, &mount_id, AT_SYMLINK_FOLLOW); if (r < 0) return false; |