Various fixes to vm_interpreted.c:

- Add opStack protection
- Fix dataMask check for OP_BLOCK_COPY
- Add instruction number check for conditional jumps
- Make errors in VM_PrepareInterpreter nonfatal
This commit is contained in:
Thilo Schulz 2011-06-16 01:11:45 +00:00
parent af5020c57c
commit 83522282f1
5 changed files with 156 additions and 169 deletions

View file

@ -949,3 +949,25 @@ void VM_LogSyscalls( int *args ) {
fprintf(f, "%i: %p (%i) = %i %i %i %i\n", callnum, (void*)(args - (int *)currentVM->dataBase),
args[0], args[1], args[2], args[3], args[4] );
}
/*
=================
VM_BlockCopy
Executes a block copy operation within currentVM data space
=================
*/
void VM_BlockCopy(unsigned int dest, unsigned int src, size_t n)
{
unsigned int dataMask = currentVM->dataMask;
if ((dest & dataMask) != dest
|| (src & dataMask) != src
|| ((dest + n) & dataMask) != dest + n
|| ((src + n) & dataMask) != src + n)
{
Com_Error(ERR_DROP, "OP_BLOCK_COPY out of range!");
}
Com_Memcpy(currentVM->dataBase + dest, currentVM->dataBase + src, n);
}