Skip to content

limit uc_mem_(read|write) size to INT_MAX #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions uc.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@ uc_err uc_mem_read(uc_engine *uc, uint64_t address, void *_bytes, size_t size)
{
uint8_t *bytes = _bytes;

// qemu cpu_physical_memory_rw() size is an int
if (size > INT_MAX)
return UC_ERR_ARG;

if (!check_mem_area(uc, address, size))
return UC_ERR_READ_UNMAPPED;

Expand Down Expand Up @@ -371,6 +375,10 @@ uc_err uc_mem_write(uc_engine *uc, uint64_t address, const void *_bytes, size_t
{
const uint8_t *bytes = _bytes;

// qemu cpu_physical_memory_rw() size is an int
if (size > INT_MAX)
return UC_ERR_ARG;

if (!check_mem_area(uc, address, size))
return UC_ERR_WRITE_UNMAPPED;

Expand Down