[FREELDR] iso.c: Perform extra validation before mounting the ISO filesystem (#7367)

Validate the primary volume descriptor version and its reported
logical block size.
This commit is contained in:
Hermès Bélusca-Maïto 2024-09-22 18:04:53 +02:00
parent 56eede6e38
commit e2d0c7de30
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -168,7 +168,7 @@ static ARC_STATUS IsoLookupFile(PCSTR FileName, ULONG DeviceId, PISO_FILE_INFO I
RtlZeroMemory(&IsoFileInfo, sizeof(ISO_FILE_INFO));
//
// Read The Primary Volume Descriptor
// Read the Primary Volume Descriptor
//
Position.HighPart = 0;
Position.LowPart = 16 * SECTORSIZE;
@ -502,9 +502,9 @@ const DEVVTBL* IsoMount(ULONG DeviceId)
TRACE("Enter IsoMount(%lu)\n", DeviceId);
//
// Read The Primary Volume Descriptor
//
/*
* Read the Primary Volume Descriptor
*/
Position.HighPart = 0;
Position.LowPart = 16 * SECTORSIZE;
Status = ArcSeek(DeviceId, &Position, SeekAbsolute);
@ -514,16 +514,24 @@ const DEVVTBL* IsoMount(ULONG DeviceId)
if (Status != ESUCCESS || Count < sizeof(PVD))
return NULL;
//
// Check if PVD is valid. If yes, return ISO9660 function table
//
if (Pvd->VdType == 1 && RtlEqualMemory(Pvd->StandardId, "CD001", 5))
/* Check if the PVD is valid */
if (!(Pvd->VdType == 1 && RtlEqualMemory(Pvd->StandardId, "CD001", 5) && Pvd->VdVersion == 1))
{
TRACE("IsoMount(%lu) success\n", DeviceId);
return &Iso9660FuncTable;
WARN("Unrecognized CDROM format\n");
return NULL;
}
if (Pvd->LogicalBlockSizeL != SECTORSIZE)
{
ERR("Unsupported LogicalBlockSize %u\n", Pvd->LogicalBlockSizeL);
return NULL;
}
return NULL;
Count = (ULONG)((ULONGLONG)Pvd->VolumeSpaceSizeL * SECTORSIZE / 1024 / 1024);
TRACE("Recognized ISO9660 drive, size %lu MB (%lu sectors)\n",
Count, Pvd->VolumeSpaceSizeL);
/* Everything OK, return the ISO9660 function table */
return &Iso9660FuncTable;
}
#endif