diff --git a/.gitignore b/.gitignore index f6e783e1..75426666 100644 --- a/.gitignore +++ b/.gitignore @@ -112,6 +112,7 @@ eflags_nosync eflags_noset mem_map_large invalid_read_in_cpu_tb_exec +invalid_read_in_cpu_tb_exec_x86_64 ################# diff --git a/tests/regress/Makefile b/tests/regress/Makefile index c0c653b6..6606ccb9 100644 --- a/tests/regress/Makefile +++ b/tests/regress/Makefile @@ -17,6 +17,7 @@ TESTS += 00opcode_uc_crash TESTS += eflags_noset TESTS += mem_map_large TESTS += invalid_read_in_cpu_tb_exec +TESTS += invalid_read_in_cpu_tb_exec_x86_64 all: $(TESTS) diff --git a/tests/regress/invalid_read_in_cpu_tb_exec_x86_64.c b/tests/regress/invalid_read_in_cpu_tb_exec_x86_64.c new file mode 100644 index 00000000..47c19f09 --- /dev/null +++ b/tests/regress/invalid_read_in_cpu_tb_exec_x86_64.c @@ -0,0 +1,26 @@ +#include + +/* + * Disassembly according to capstone: + * mulx rsp, rsp, rdx + */ +#define BINARY "\xc4\xe2\xdb\xf6\xe2" +#define MEMORY_SIZE 2 * 1024 * 1024 +#define STARTING_ADDRESS 0x1000000 + +int main(int argc, char **argv, char **envp) { + uc_engine *uc; + if (uc_open(UC_ARCH_X86, UC_MODE_64, &uc)) { + printf("uc_open(…) failed\n"); + return 1; + } + uc_mem_map(uc, STARTING_ADDRESS, MEMORY_SIZE, UC_PROT_ALL); + if (uc_mem_write(uc, STARTING_ADDRESS, BINARY, sizeof(BINARY) - 1)) { + printf("uc_mem_write(…) failed\n"); + return 1; + } + printf("uc_emu_start(…)\n"); + uc_emu_start(uc, STARTING_ADDRESS, STARTING_ADDRESS + sizeof(BINARY) - 1, 0, 20); + printf("done\n"); + return 0; +}