mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 14:25:52 +00:00
[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.
svn path=/trunk/; revision=70424
This commit is contained in:
parent
c6ab198d15
commit
060e447a77
2 changed files with 5 additions and 5 deletions
|
@ -608,8 +608,8 @@ VOID WINAPI BiosDiskService(LPWORD Stack)
|
||||||
setAH(0x03);
|
setAH(0x03);
|
||||||
|
|
||||||
/* Number of 512-byte sectors in CX:DX */
|
/* Number of 512-byte sectors in CX:DX */
|
||||||
NumSectors = DiskImage->DiskInfo.Cylinders * DiskImage->DiskInfo.Heads
|
NumSectors = (ULONG)((ULONG)DiskImage->DiskInfo.Cylinders * DiskImage->DiskInfo.Heads)
|
||||||
* DiskImage->DiskInfo.Sectors;
|
* DiskImage->DiskInfo.Sectors;
|
||||||
setCX(HIWORD(NumSectors));
|
setCX(HIWORD(NumSectors));
|
||||||
setDX(LOWORD(NumSectors));
|
setDX(LOWORD(NumSectors));
|
||||||
}
|
}
|
||||||
|
|
|
@ -342,7 +342,7 @@ SeekDisk(IN PDISK_IMAGE DiskImage,
|
||||||
|
|
||||||
/* Set position */
|
/* Set position */
|
||||||
// Compute the offset
|
// 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.Sectors + (Sector - 1))
|
||||||
* DiskImage->DiskInfo.SectorSize;
|
* DiskImage->DiskInfo.SectorSize;
|
||||||
FilePointer = SetFilePointer(DiskImage->hDisk, FilePointer, NULL, FILE_BEGIN);
|
FilePointer = SetFilePointer(DiskImage->hDisk, FilePointer, NULL, FILE_BEGIN);
|
||||||
|
@ -373,7 +373,7 @@ ReadDisk(IN PDISK_IMAGE DiskImage,
|
||||||
if (Result != 0x00)
|
if (Result != 0x00)
|
||||||
return Result;
|
return Result;
|
||||||
|
|
||||||
BytesToRead = NumSectors * DiskImage->DiskInfo.SectorSize;
|
BytesToRead = (DWORD)NumSectors * DiskImage->DiskInfo.SectorSize;
|
||||||
|
|
||||||
// FIXME: Consider just looping around filling each time the buffer...
|
// FIXME: Consider just looping around filling each time the buffer...
|
||||||
|
|
||||||
|
@ -434,7 +434,7 @@ WriteDisk(IN PDISK_IMAGE DiskImage,
|
||||||
if (Result != 0x00)
|
if (Result != 0x00)
|
||||||
return Result;
|
return Result;
|
||||||
|
|
||||||
BytesToWrite = NumSectors * DiskImage->DiskInfo.SectorSize;
|
BytesToWrite = (DWORD)NumSectors * DiskImage->DiskInfo.SectorSize;
|
||||||
|
|
||||||
// FIXME: Consider just looping around filling each time the buffer...
|
// FIXME: Consider just looping around filling each time the buffer...
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue