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

eepmake: Fix parse_data sscanf #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nekuz0r
Copy link

@nekuz0r nekuz0r commented Nov 19, 2020

%2X format string reads sizeof(int) bytes, but only 2 hexadecimal characters are supplied by c pointer which is 1 byte long.
Using %2hhX tells sscanf to read sizeof(char) bytes or 1 byte.

On system where sizeof(int) == sizeof(char) this is no issue but on other ones, the arithmetic operation (unsigned int*)*data+data_len++ is increasing the pointer sizeof(int) bytes instead instead of 1 byte.

`%2X` format string reads `sizeof(int)` bytes, but only 2 hexadecimal characters are supplied by `c` pointer which is 1 byte long.
Using `%2hhX` tells sscanf to read sizeof(char) bytes or 1 byte.

On system where sizeof(int) == sizeof(char) this is no issue but on other ones, the arithmetic operation `(unsigned int*)*data+data_len++` is increasing the pointer sizeof(int) bytes instead instead of 1 byte.
@nekuz0r
Copy link
Author

nekuz0r commented Nov 19, 2020

I forgot to emphasis that this issue can lead to a buffer overflow situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant