Skip to content

Commit e2d0c7d

Browse files
committed
[FREELDR] iso.c: Perform extra validation before mounting the ISO filesystem (reactos#7367)
Validate the primary volume descriptor version and its reported logical block size.
1 parent 56eede6 commit e2d0c7d

File tree

1 file changed

+19
-11
lines changed
  • boot/freeldr/freeldr/lib/fs

1 file changed

+19
-11
lines changed

boot/freeldr/freeldr/lib/fs/iso.c

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ static ARC_STATUS IsoLookupFile(PCSTR FileName, ULONG DeviceId, PISO_FILE_INFO I
168168
RtlZeroMemory(&IsoFileInfo, sizeof(ISO_FILE_INFO));
169169

170170
//
171-
// Read The Primary Volume Descriptor
171+
// Read the Primary Volume Descriptor
172172
//
173173
Position.HighPart = 0;
174174
Position.LowPart = 16 * SECTORSIZE;
@@ -502,9 +502,9 @@ const DEVVTBL* IsoMount(ULONG DeviceId)
502502

503503
TRACE("Enter IsoMount(%lu)\n", DeviceId);
504504

505-
//
506-
// Read The Primary Volume Descriptor
507-
//
505+
/*
506+
* Read the Primary Volume Descriptor
507+
*/
508508
Position.HighPart = 0;
509509
Position.LowPart = 16 * SECTORSIZE;
510510
Status = ArcSeek(DeviceId, &Position, SeekAbsolute);
@@ -514,16 +514,24 @@ const DEVVTBL* IsoMount(ULONG DeviceId)
514514
if (Status != ESUCCESS || Count < sizeof(PVD))
515515
return NULL;
516516

517-
//
518-
// Check if PVD is valid. If yes, return ISO9660 function table
519-
//
520-
if (Pvd->VdType == 1 && RtlEqualMemory(Pvd->StandardId, "CD001", 5))
517+
/* Check if the PVD is valid */
518+
if (!(Pvd->VdType == 1 && RtlEqualMemory(Pvd->StandardId, "CD001", 5) && Pvd->VdVersion == 1))
521519
{
522-
TRACE("IsoMount(%lu) success\n", DeviceId);
523-
return &Iso9660FuncTable;
520+
WARN("Unrecognized CDROM format\n");
521+
return NULL;
524522
}
523+
if (Pvd->LogicalBlockSizeL != SECTORSIZE)
524+
{
525+
ERR("Unsupported LogicalBlockSize %u\n", Pvd->LogicalBlockSizeL);
526+
return NULL;
527+
}
528+
529+
Count = (ULONG)((ULONGLONG)Pvd->VolumeSpaceSizeL * SECTORSIZE / 1024 / 1024);
530+
TRACE("Recognized ISO9660 drive, size %lu MB (%lu sectors)\n",
531+
Count, Pvd->VolumeSpaceSizeL);
525532

526-
return NULL;
533+
/* Everything OK, return the ISO9660 function table */
534+
return &Iso9660FuncTable;
527535
}
528536

529537
#endif

0 commit comments

Comments
 (0)