Author: pschweitzer
Date: Sun Apr 27 18:46:26 2014
New Revision: 63023
URL:
http://svn.reactos.org/svn/reactos?rev=63023&view=rev
Log:
[NTOSKRNL]
Fix potential overflows
CID #701302
CID #1206856
Modified:
trunk/reactos/ntoskrnl/fstub/fstubex.c
Modified: trunk/reactos/ntoskrnl/fstub/fstubex.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fstub/fstubex.c?r…
==============================================================================
--- trunk/reactos/ntoskrnl/fstub/fstubex.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/fstub/fstubex.c [iso-8859-1] Sun Apr 27 18:46:26 2014
@@ -1006,7 +1006,7 @@
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 @@
}
/* 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;