In case of directory enumeration, validate the record earlier to really prevent any potentiel buffer overflow

CORE-9254

svn path=/trunk/; revision=68244
This commit is contained in:
Pierre Schweitzer 2015-06-23 06:54:44 +00:00
parent 5ab078c226
commit f710a888d6

View file

@ -117,6 +117,12 @@ CdfsGetEntryName(PDEVICE_EXTENSION DeviceExt,
DPRINT("Index %lu RecordLength %lu Offset %lu\n", DPRINT("Index %lu RecordLength %lu Offset %lu\n",
*pIndex, Record->RecordLength, *CurrentOffset); *pIndex, Record->RecordLength, *CurrentOffset);
if (!CdfsIsRecordValid(DeviceExt, Record))
{
CcUnpinData(*Context);
return STATUS_DISK_CORRUPT_ERROR;
}
CdfsGetDirEntryName(DeviceExt, Record, Name); CdfsGetDirEntryName(DeviceExt, Record, Name);
*Ptr = Record; *Ptr = Record;
@ -259,20 +265,13 @@ CdfsFindFile(PDEVICE_EXTENSION DeviceExt,
{ {
break; break;
} }
else if (Status == STATUS_UNSUCCESSFUL) else if (Status == STATUS_UNSUCCESSFUL || Status == STATUS_DISK_CORRUPT_ERROR)
{ {
/* Note: the directory cache has already been unpinned */ /* Note: the directory cache has already been unpinned */
RtlFreeUnicodeString(&FileToFindUpcase); RtlFreeUnicodeString(&FileToFindUpcase);
return Status; return Status;
} }
if (!CdfsIsRecordValid(DeviceExt, Record))
{
RtlFreeUnicodeString(&FileToFindUpcase);
CcUnpinData(Context);
return STATUS_DISK_CORRUPT_ERROR;
}
DPRINT("Name '%S'\n", name); DPRINT("Name '%S'\n", name);
RtlInitUnicodeString(&LongName, name); RtlInitUnicodeString(&LongName, name);