mirror of
https://github.com/reactos/reactos.git
synced 2024-09-28 13:34:53 +00:00
[FREELDR] hwdisk: Add sanity checks to avoid infinite loop (#1731)
CORE-16204 CORE-16205
This commit is contained in:
parent
5dbc677cdd
commit
31aca248a1
|
@ -82,6 +82,13 @@ DiskOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
|
|||
PARTITION_TABLE_ENTRY PartitionTableEntry;
|
||||
CHAR FileName[1];
|
||||
|
||||
if (DiskReadBufferSize == 0)
|
||||
{
|
||||
ERR("DiskOpen(): DiskReadBufferSize is 0, something is wrong.\n");
|
||||
ASSERT(FALSE);
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
if (!DissectArcPath(Path, FileName, &DriveNumber, &DrivePartition))
|
||||
return EINVAL;
|
||||
|
||||
|
@ -139,10 +146,16 @@ DiskRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count)
|
|||
BOOLEAN ret;
|
||||
ULONGLONG SectorOffset;
|
||||
|
||||
ASSERT(DiskReadBufferSize > 0);
|
||||
|
||||
TotalSectors = (N + Context->SectorSize - 1) / Context->SectorSize;
|
||||
MaxSectors = DiskReadBufferSize / Context->SectorSize;
|
||||
SectorOffset = Context->SectorNumber + Context->SectorOffset;
|
||||
|
||||
// If MaxSectors is 0, this will lead to infinite loop
|
||||
// In release builds assertions are disabled, however we also have sanity checks in DiskOpen()
|
||||
ASSERT(MaxSectors > 0);
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
while (TotalSectors)
|
||||
|
|
Loading…
Reference in a new issue