Skip to content

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