add check for mem_map(size=0) (#14)
This commit is contained in:
parent
ee9e2d6a12
commit
76d8541717
@ -53,6 +53,7 @@ __all__ = [
|
||||
'UC_ERR_CODE_INVALID',
|
||||
'UC_ERR_HOOK',
|
||||
'UC_ERR_INSN_INVALID',
|
||||
'UC_ERR_MAP',
|
||||
|
||||
'UC_HOOK_INTR',
|
||||
'UC_HOOK_INSN',
|
||||
@ -122,6 +123,7 @@ UC_ERR_MEM_WRITE = 8 # Quit emulation due to invalid memory WRITE: uc_emu_st
|
||||
UC_ERR_CODE_INVALID = 9 # Quit emulation due to invalid code address: uc_emu_start()
|
||||
UC_ERR_HOOK = 10 # Invalid hook type: uc_hook_add()
|
||||
UC_ERR_INSN_INVALID = 11 # Invalid instruction
|
||||
UC_ERR_MAP = 12 # Invalid memory mapping
|
||||
|
||||
|
||||
# All type of hooks for uc_hook_add() API.
|
||||
|
@ -116,6 +116,7 @@ typedef enum uc_err {
|
||||
UC_ERR_CODE_INVALID, // Quit emulation due to invalid code address: uc_emu_start()
|
||||
UC_ERR_HOOK, // Invalid hook type: uc_hook_add()
|
||||
UC_ERR_INSN_INVALID, // Quit emulation due to invalid instruction: uc_emu_start()
|
||||
UC_ERR_MAP, // Invalid memory mapping: uc_mem_map()
|
||||
} uc_err;
|
||||
|
||||
|
||||
|
6
uc.c
6
uc.c
@ -126,6 +126,8 @@ const char *uc_strerror(uc_err code)
|
||||
return "Invalid instruction (UC_ERR_INSN_INVALID)";
|
||||
case UC_ERR_HOOK:
|
||||
return "Invalid hook type (UC_ERR_HOOK)";
|
||||
case UC_ERR_MAP:
|
||||
return "Invalid memory mapping (UC_ERR_MAP)";
|
||||
}
|
||||
}
|
||||
|
||||
@ -552,6 +554,10 @@ uc_err uc_mem_map(uch handle, uint64_t address, size_t size)
|
||||
// invalid handle
|
||||
return UC_ERR_UCH;
|
||||
|
||||
if (size == 0)
|
||||
// invalid memory mapping
|
||||
return UC_ERR_MAP;
|
||||
|
||||
// align to 8KB boundary
|
||||
map_begin[map_count] = address & (~ (8*1024 - 1));
|
||||
s = (size + 8*1024 - 1) & (~ (8*1024 - 1));
|
||||
|
Loading…
Reference in New Issue
Block a user