diff --git a/src/machine-vuln4.c b/src/machine-vuln4.c index 916c9f6ed43469855e6f477af7110dec840c9726..7ade421004ab3f45b0fdb2f71d70a0ce3ca72751 100644 --- a/src/machine-vuln4.c +++ b/src/machine-vuln4.c @@ -58,7 +58,7 @@ static void machine_init(void){ memory = malloc(sizeof(int32_t)*MEMORY_SIZE); regs = malloc(sizeof(int32_t)*NUM_REGS); memset(memory,0,sizeof(int32_t)*MEMORY_SIZE); - memset(regs,0,sizeof(int32_t)*NUM_REGS); + memset(regs,0,sizeof(int32_t)*(NUM_REGS-1)); count = 0; } diff --git a/src/machine-vuln5.c b/src/machine-vuln5.c index 916c9f6ed43469855e6f477af7110dec840c9726..5acfac9041cc4710ec70439b6ff3f5667dc23e2a 100644 --- a/src/machine-vuln5.c +++ b/src/machine-vuln5.c @@ -57,8 +57,8 @@ unsigned int count = 0; /* counts number of instructions executed so far */ static void machine_init(void){ memory = malloc(sizeof(int32_t)*MEMORY_SIZE); regs = malloc(sizeof(int32_t)*NUM_REGS); - memset(memory,0,sizeof(int32_t)*MEMORY_SIZE); - memset(regs,0,sizeof(int32_t)*NUM_REGS); + //memset(memory,0,sizeof(int32_t)*MEMORY_SIZE); + // memset(regs,0,sizeof(int32_t)*NUM_REGS); count = 0; } @@ -226,7 +226,7 @@ int execute(const unsigned int progLength, const int cycles, int32_t * res){ unsigned int cyclesExecuted = 0; while(cycles > 0 ? cyclesExecuted < (unsigned int)cycles : true){ cyclesExecuted++; - if (pc < 0 || pc >= (int)progLength){ + if (pc >= (int)progLength){ /* will cause an error but that is not a bug and * and indeed is what the VM is supposed to do if the pc becomes * negative, since in this case the program's execution finishes @@ -406,11 +406,11 @@ int execute(const unsigned int progLength, const int cycles, int32_t * res){ count++; continue; /* avoid default increment the pc below */ } else { - return -1; + return -1; } }else{ debug_printf("Unrecognised opcode: %s\n",toks[0]); - return -1; + return -1; } count++; pc = pc + 1; diff --git a/src/pocs/poc4.s b/src/pocs/poc4.s index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..3f00d45a0171ddaabec1376567c738d3fa33f9e7 100644 --- a/src/pocs/poc4.s +++ b/src/pocs/poc4.s @@ -0,0 +1 @@ + pw.println("RET R31"); \ No newline at end of file