mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 10:05:40 +00:00
Add regression test for the map crash
This commit is contained in:
parent
c55ad00e2a
commit
ba39dd3374
11
regress/Makefile
Normal file
11
regress/Makefile
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
CFLAGS+=-I../include
|
||||||
|
LDFLAGS=-L.. -lunicorn
|
||||||
|
|
||||||
|
TESTS=map_crash map_regs
|
||||||
|
|
||||||
|
all: $(TESTS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(TESTS)
|
||||||
|
|
||||||
|
.PHONY: all clean
|
29
regress/map_crash.c
Normal file
29
regress/map_crash.c
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#include <unicorn/unicorn.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define UC_BUG_WRITE_SIZE 13000
|
||||||
|
#define UC_BUG_WRITE_ADDR 0x1000
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int size;
|
||||||
|
uint8_t *buf;
|
||||||
|
uch uh;
|
||||||
|
uc_err err = uc_open (UC_ARCH_X86, UC_MODE_64, &uh);
|
||||||
|
if (err) {
|
||||||
|
fprintf (stderr, "Cannot initialize unicorn\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
size = UC_BUG_WRITE_SIZE;
|
||||||
|
buf = malloc (size);
|
||||||
|
if (!buf) {
|
||||||
|
fprintf (stderr, "Cannot allocate\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
memset (buf, 0, size);
|
||||||
|
uc_mem_map (uh, UC_BUG_WRITE_ADDR, size);
|
||||||
|
uc_mem_write (uh, UC_BUG_WRITE_ADDR, buf, size);
|
||||||
|
uc_close (&uh);
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in a new issue