Skip to content
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

Buffer overflow when reading large registers #3

Closed
dargueta opened this issue Aug 29, 2019 · 1 comment
Closed

Buffer overflow when reading large registers #3

dargueta opened this issue Aug 29, 2019 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@dargueta
Copy link
Owner

dargueta commented Aug 29, 2019

The current code for reading a register looks like this:

lua_Unsigned value = 0;
error = uc_reg_read(engine, register_id, &value);

On Lua 5.3, integers are 64 bits, so this will result in a buffer overflow when reading the 128-bit XMMX/YMMX etc. registers on an Intel machine. Similarly, reading a 64-bit register on any 32-bit Lua installation will also result in a buffer overflow.

@dargueta dargueta added the bug Something isn't working label Aug 29, 2019
@dargueta dargueta self-assigned this Aug 29, 2019
@dargueta
Copy link
Owner Author

Partially solved by b0e36de; reads now use uint_least64_t so reading 64-bit registers is guaranteed to be fine, even on 32-bit versions of Lua. On systems where uint_least64_t is larger than 64 bits, reads up to that width will be fine too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant