hats
hats copied to clipboard
eepmake: Fix parse_data sscanf
%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.
I forgot to emphasis that this issue can lead to a buffer overflow situation.