Add error-checking to InternalGetNextAttribute(); don't crash if CurrAttr->Length is invalid.

svn path=/branches/GSoC_2016/NTFS/; revision=71897
This commit is contained in:
Trevor Thompson 2016-07-12 09:57:16 +00:00 committed by Thomas Faber
parent de5cff4b37
commit 7c576a836f

View file

@ -181,6 +181,14 @@ InternalGetNextAttribute(PFIND_ATTR_CONTXT Context)
}
NextAttribute = (PNTFS_ATTR_RECORD)((ULONG_PTR)Context->CurrAttr + Context->CurrAttr->Length);
if (NextAttribute > Context->LastAttr || NextAttribute < Context->FirstAttr)
{
DPRINT1("Broken length: 0x%lx!\n", Context->CurrAttr->Length);
Context->CurrAttr = (PVOID)-1;
return NULL;
}
Context->Offset += ((ULONG_PTR)NextAttribute - (ULONG_PTR)Context->CurrAttr);
Context->CurrAttr = NextAttribute;