boot: add overflow check in GPT parser

ALIGN_TO() can overflow and return SIZE_MAX

CID#1644887

Follow-up for ccbd324a3a
This commit is contained in:
Luca Boccassi
2026-03-28 18:29:28 +00:00
parent 9bdc8c8138
commit 85b20f5fa7

View 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,