fix cow when using uc_mem_write

memory_cow expect the address and size to be aligned on pagesize.
This commit is contained in:
Takacs, Philipp
2024-01-09 17:06:49 +01:00
parent e0eeda2362
commit 8d3bf02041
2 changed files with 7 additions and 1 deletions

5
uc.c
View File

@@ -788,7 +788,10 @@ uc_err uc_mem_write(uc_engine *uc, uint64_t address, const void *_bytes,
len = memory_region_len(uc, mr, address, size - count);
if (uc->snapshot_level && uc->snapshot_level > mr->priority) {
mr = uc->memory_cow(uc, mr, address, len);
mr = uc->memory_cow(uc, mr, address & ~uc->target_page_align,
(len + (address & uc->target_page_align) +
uc->target_page_align) &
~uc->target_page_align);
if (!mr) {
return UC_ERR_NOMEM;
}