mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 10:25:28 +00:00
Merge pull request #270 from practicalswift/invalid-write-in-cpu_tb_exec_x86_64
Crash case: Invalid write of size 4 in cpu_tb_exec_x86_64 (issue #269)
This commit is contained in:
commit
51945c5bf2
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -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
|
||||
|
||||
|
||||
#################
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
26
tests/regress/invalid_read_in_cpu_tb_exec_x86_64.c
Normal file
26
tests/regress/invalid_read_in_cpu_tb_exec_x86_64.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include <unicorn/unicorn.h>
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
Loading…
Reference in a new issue