KiTrap0DHandler: fix buffer overrun (Spotted by Amine Khaldi) and optimize the code by checking the counter variable, instead of Instruction, this works the same, but the compiler can make sense of it and safe one comparison.
svn path=/trunk/; revision=45132
/* FIXME: Use SEH */
Instructions = (PUCHAR)TrapFrame->Eip;
- /* Scan next 15 opcodes */
+ /* Scan next 15 bytes */
for (i = 0; i < 15; i++)
{
/* Skip prefix instructions */
}
/* Is this NOT any prefix instruction? */
- if (Instructions[i] != KiTrapPrefixTable[j])
+ if (j == sizeof(KiTrapPrefixTable))
{
/* We can go ahead and handle the fault now */
Instruction = Instructions[i];
}
/* If all we found was prefixes, then this instruction is too long */
- if (!Instruction)
+ if (i == 15)
{
/* Setup illegal instruction fault */
KiDispatchException0Args(STATUS_ILLEGAL_INSTRUCTION,