freebsd-nq/usr.sbin/makefs
Jessica Clarke b0ce7dfc5e makefs: Fix 32-bit issues in ZFS time attributes setting
Currently the code copies a struct timespec's raw bits as a pair of
uint64_t. On 64-bit systems this has the same representation, but on
32-bit issues there are two issues:

1. tv_sec is a time_t which is 32-bit on i386 specifically
2. tv_nsec is a long not a 64-bit integer

On i386, this means the assertion should fire as the size doesn't match.
On other 32-bit systems there are 4 bytes of padding after tv_nsec,
which in practice are probably 0, as this data is ultimately coming from
the kernel, so it's deterministic (though the padding bytes are not
required to be preserved by the compiler, so are strictly unspecified).
However, on 32-bit big-endian systems, the padding bytes are in the
wrong half to be harmless, resulting in the nanoseconds being multiplied
by 2^32.

Fix this all by marshalling via a real uint64_t pair like is done by the
real ZFS_TIME_ENCODE.

Reviewed by:	markj
Fixes:		240afd8c1f ("makefs: Add ZFS support")
Differential Revision:	https://reviews.freebsd.org/D36131
2022-08-18 02:46:27 +01:00
..
cd9660 makefs(8): Fix a few typos in source code comments 2022-02-06 13:46:38 +01:00
ffs makefs(8): Fix a few typos in source code comments 2022-02-06 13:46:38 +01:00
msdos makefs: Fix warnings and reset WARNS to the default 2022-05-10 17:38:23 -04:00
sys Fix makefs bootstrap after d485c77f20 2021-02-22 17:55:45 +00:00
tests makefs tests: Add test cases for handling of multiple staging dirs 2022-08-17 17:28:01 -04:00
zfs makefs: Fix 32-bit issues in ZFS time attributes setting 2022-08-18 02:46:27 +01:00
cd9660.c
cd9660.h Fix -Wpointer-sign warnings in makefs and mkimg 2021-01-07 09:26:21 +00:00
ffs.c makefs: fix calculation of file sizes 2022-05-16 16:32:10 -06:00
ffs.h Allocate extra inodes in makefs when leaving free space in UFS images. 2021-04-06 13:43:29 -04:00
Makefile makefs: Add ZFS support 2022-08-05 13:42:29 -04:00
Makefile.depend
makefs.8 makefs: Add ZFS support 2022-08-05 13:42:29 -04:00
makefs.c makefs: Add ZFS support 2022-08-05 13:42:29 -04:00
makefs.h makefs: Add ZFS support 2022-08-05 13:42:29 -04:00
msdos.c makefs: remove set but not used variables 2021-11-21 21:21:34 -05:00
msdos.h Fix makefs bootstrap after d485c77f20 2021-02-22 17:55:45 +00:00
mtree.c makefs: Ignore the "tags" keyword in mtree manifests 2021-03-23 14:38:40 -04:00
walk.c
zfs.c makefs: Style 2022-08-16 14:21:44 -04:00