From 5cabd6269f88ffb257ea78d1b93d8c3ac952bb71 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sun, 27 Apr 2014 18:46:26 +0000 Subject: [PATCH] [NTOSKRNL] Fix potential overflows CID #701302 CID #1206856 svn path=/trunk/; revision=63023 --- reactos/ntoskrnl/fstub/fstubex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/ntoskrnl/fstub/fstubex.c b/reactos/ntoskrnl/fstub/fstubex.c index e864c1f09cd..d039e718b1c 100644 --- a/reactos/ntoskrnl/fstub/fstubex.c +++ b/reactos/ntoskrnl/fstub/fstubex.c @@ -1006,7 +1006,7 @@ FstubReadPartitionTableEFI(IN PDISK_INFORMATION Disk, if ((Disk->SectorCount - 1ULL) != EfiHeader->AlternateLBA) { /* We'll update it. First, count number of sectors needed to store partitions */ - SectorsForPartitions = (EfiHeader->NumberOfEntries * PARTITION_ENTRY_SIZE) / Disk->SectorSize; + SectorsForPartitions = ((ULONGLONG)EfiHeader->NumberOfEntries * PARTITION_ENTRY_SIZE) / Disk->SectorSize; /* Then set first usable LBA: Legacy MBR + GPT header + Partitions entries */ EfiHeader->FirstUsableLBA = SectorsForPartitions + 2; /* Then set last usable LBA: Last sector - GPT header - Partitions entries */ @@ -1313,7 +1313,7 @@ FstubVerifyPartitionTableEFI(IN PDISK_INFORMATION Disk, } /* Compute sectors taken by partitions */ - SectorsForPartitions = ((EFIHeader->NumberOfEntries * PARTITION_ENTRY_SIZE) + Disk->SectorSize - 1) / Disk->SectorSize; + SectorsForPartitions = (((ULONGLONG)EFIHeader->NumberOfEntries * PARTITION_ENTRY_SIZE) + Disk->SectorSize - 1) / Disk->SectorSize; if (PrimaryValid) { WriteBackup = TRUE;