hats icon indicating copy to clipboard operation
hats copied to clipboard

eepmake: Fix parse_data sscanf

Open nekuz0r opened this issue 4 years ago • 1 comments

%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 avatar Nov 19 '20 10:11 nekuz0r

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

nekuz0r avatar Nov 19 '20 10:11 nekuz0r