add check for mem_map(size=0) (#14)

This commit is contained in:
Ryan Hileman
2015-08-23 14:16:40 -07:00
parent ee9e2d6a12
commit 76d8541717
3 changed files with 9 additions and 0 deletions

6
uc.c
View File

@@ -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));