]> git.ipfire.org Git - thirdparty/util-linux.git/commit
libfdisk: Fix randomly generated GPT UUID's
authorToomas Losin <tlo@lenrek.net>
Sun, 5 Mar 2023 23:57:55 +0000 (15:57 -0800)
committerKarel Zak <kzak@redhat.com>
Thu, 9 Mar 2023 11:15:25 +0000 (12:15 +0100)
commitdd405ea745e451fb0cf32e9dedd94d69850fe333
tree40ba1b601eee88ba52338cacb98dbee126007c7d
parent2af05775a12581020d8d83a0a55519f15fc74178
libfdisk: Fix randomly generated GPT UUID's

Fdisk commands that create random GPT UUID's result in values that are
not UEFI-compliant being written to disk: The "g" command creates a
new GPT whose in-core DiskGUID value is entirely big-endian; the "n"
command creates a GPT partition whose in-core UniquePartitionGUID
value is entirely big-endian.  Those big-endian values are written to
disk by the "w" command rather than the mix of little- and big-endian
spec'd by UEFI.

This was caused by a libfdisk patch in 2017 that was addressing
warnings about "taking address of packed member".  Reading gpt.c finds
two instances of dead code which suggests that perhaps there was some
confusion between a struct and a pointer to a struct.  The intent must
have been to convert the randomly generated big-endian RFC 4122 UUID
values to UEFI's mixed-endian but the confusion(?) resulted in some
dead code and non-conversion of the UUID's.

This patch corrects the breakage while still avoiding "taking address
of packed member" warnings.  The "w" command will once again write
UEFI-compliant values to disk.

Fixes: 92e486f80ef8 ("libfdisk: fix guid usage of packed struct gpt_entry")
Signed-off-by: Toomas Losin <tlo@lenrek.net>
libfdisk/src/gpt.c