]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
gpt: Add compile time asserts for guid and gpt_partentry sizes
authorVladimir Serbinenko <phcoder@gmail.com>
Sun, 13 Aug 2023 07:18:53 +0000 (09:18 +0200)
committerVladimir Serbinenko <phcoder@gmail.com>
Wed, 8 Nov 2023 04:05:06 +0000 (05:05 +0100)
With new alignment specification it's easy to screw up. Fortunately if it
happens the size will be bigger than intended. Compile time assert will catch
this.

Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/partmap/gpt.c

index 877ceefc33e12799c2f0b50d8e5e1eec5381674c..426f616aea3c6e6f4d464437ec2846dd8f355ca9 100644 (file)
@@ -229,6 +229,9 @@ static struct grub_partition_map grub_gpt_partition_map =
 
 GRUB_MOD_INIT(part_gpt)
 {
+  COMPILE_TIME_ASSERT(sizeof(grub_guid_t) == 16);
+  COMPILE_TIME_ASSERT(sizeof(grub_packed_guid_t) == 16);
+  COMPILE_TIME_ASSERT(sizeof(struct grub_gpt_partentry) == 128);
   grub_partition_map_register (&grub_gpt_partition_map);
 }