]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: add overflow check in GPT parser
authorLuca Boccassi <luca.boccassi@gmail.com>
Sat, 28 Mar 2026 18:29:28 +0000 (18:29 +0000)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sat, 28 Mar 2026 19:56:31 +0000 (19:56 +0000)
ALIGN_TO() can overflow and return SIZE_MAX

CID#1644887

Follow-up for ccbd324a3a522362de0863e8d06cdd06a58d2fca

src/boot/part-discovery.c

index dc1aed0514b1d2b3f03898dd2a9dce6aa70c3689..25f60521acf30b4aa5881a0766ec1c826518f15f 100644 (file)
@@ -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,