Author: hbelusca
Date: Sat Dec 26 17:08:13 2015
New Revision: 70424
URL:
http://svn.reactos.org/svn/reactos?rev=70424&view=rev
Log:
[NTVDM]: Cast all the number-of-sectors computations to DWORD/ULONG to prevent potential
overflows. Should fix a strange floppy read/write corruption I noticed.
Modified:
trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/dskbios32.c
trunk/reactos/subsystems/mvdm/ntvdm/hardware/disk.c
Modified: trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/dskbios32.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/bios…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/dskbios32.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/dskbios32.c [iso-8859-1] Sat Dec 26
17:08:13 2015
@@ -608,8 +608,8 @@
setAH(0x03);
/* Number of 512-byte sectors in CX:DX */
- NumSectors = DiskImage->DiskInfo.Cylinders *
DiskImage->DiskInfo.Heads
- *
DiskImage->DiskInfo.Sectors;
+ NumSectors = (ULONG)((ULONG)DiskImage->DiskInfo.Cylinders *
DiskImage->DiskInfo.Heads)
+ *
DiskImage->DiskInfo.Sectors;
setCX(HIWORD(NumSectors));
setDX(LOWORD(NumSectors));
}
Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/disk.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hard…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/hardware/disk.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/disk.c [iso-8859-1] Sat Dec 26 17:08:13
2015
@@ -342,7 +342,7 @@
/* Set position */
// Compute the offset
- FilePointer = ((Cylinder * DiskImage->DiskInfo.Heads + Head)
+ FilePointer = (DWORD)((DWORD)((DWORD)Cylinder * DiskImage->DiskInfo.Heads + Head)
* DiskImage->DiskInfo.Sectors + (Sector - 1))
* DiskImage->DiskInfo.SectorSize;
FilePointer = SetFilePointer(DiskImage->hDisk, FilePointer, NULL, FILE_BEGIN);
@@ -373,7 +373,7 @@
if (Result != 0x00)
return Result;
- BytesToRead = NumSectors * DiskImage->DiskInfo.SectorSize;
+ BytesToRead = (DWORD)NumSectors * DiskImage->DiskInfo.SectorSize;
// FIXME: Consider just looping around filling each time the buffer...
@@ -434,7 +434,7 @@
if (Result != 0x00)
return Result;
- BytesToWrite = NumSectors * DiskImage->DiskInfo.SectorSize;
+ BytesToWrite = (DWORD)NumSectors * DiskImage->DiskInfo.SectorSize;
// FIXME: Consider just looping around filling each time the buffer...