From 85b20f5fa7291eaf7effe62d88a8c0d5b79eee7c Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Sat, 28 Mar 2026 18:29:28 +0000 Subject: [PATCH] boot: add overflow check in GPT parser ALIGN_TO() can overflow and return SIZE_MAX CID#1644887 Follow-up for ccbd324a3a522362de0863e8d06cdd06a58d2fca --- src/boot/part-discovery.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/boot/part-discovery.c b/src/boot/part-discovery.c index dc1aed0514..25f60521ac 100644 --- a/src/boot/part-discovery.c +++ b/src/boot/part-discovery.c @@ -117,6 +117,8 @@ static EFI_STATUS try_gpt( /* Now load the GPT entry table */ size = ALIGN_TO((size_t) gpt->SizeOfPartitionEntry * (size_t) gpt->NumberOfPartitionEntries, 512); + if (size == SIZE_MAX) /* overflow check */ + return EFI_OUT_OF_RESOURCES; entries_pages = xmalloc_aligned_pages( AllocateMaxAddress, EfiLoaderData,