]> git.ipfire.org Git - thirdparty/util-linux.git/commit
libfdisk: fix use of on-disk sizeof_partition_entry in GPT
authorKarel Zak <kzak@redhat.com>
Tue, 26 May 2026 14:16:03 +0000 (16:16 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 26 May 2026 14:16:03 +0000 (16:16 +0200)
commitefb0dbd34cd439e94288933948af394397ac6dc7
treea57fc7d0e51cfc034d255d822b560dd5635acb25
parentc906dbb72ed5fd8718beda367de883b41bc7ae1c
libfdisk: fix use of on-disk sizeof_partition_entry in GPT

The GPT code hardcodes sizeof(struct gpt_entry) (128 bytes) in
several places instead of using the on-disk sizeof_partition_entry
field from the GPT header. The UEFI specification allows entry sizes
larger than 128 bytes.

 - reject GPT headers where sizeof_partition_entry is smaller than
   sizeof(struct gpt_entry) to prevent out-of-bounds reads when
   accessing entry array elements

 - use the on-disk entry size as the qsort element stride in
   gpt_reorder() to avoid corrupting entries when sizeof_partition_entry
   differs from 128

 - use the on-disk entry size in gpt_copy_header() when calculating
   the backup partition entry array LBA

Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/gpt.c