madsen / vbindiff

Visual Binary Diff (VBinDiff) displays files in hex & ASCII and can highlight the differences between 2 files
479 stars 52 forks source link

some gcc7 warnings #11

Open dodona2 opened 6 years ago

dodona2 commented 6 years ago

just for the case it is not known:

vbindiff.cpp: In member function ‘void FileDisplay::setByte(short int, short int, Byte)’: vbindiff.cpp:635:6: warning: ‘%02X’ directive writing between 2 and 8 bytes into a region of size 3 [-Wformat-overflow=] void FileDisplay::setByte(short x, short y, Byte b) ^~~ vbindiff.cpp:635:6: note: directive argument in the range [0, 2147483647] vbindiff.cpp:659:12: note: ‘sprintf’ output between 3 and 9 bytes into a destination of size 3 sprintf(str, "%02X", b);

nfllab commented 6 years ago

Any idea why gcc7 thinks that b is between 0 and 2147483647? It's unsigned char.

mrdudz commented 6 years ago

the format string expects a long, and b is promoted to int. iirc :)

dodona2 commented 6 years ago

'the format string expects a long, and b is promoted to int. iirc :)' can someone please fix ithis?

nfllab commented 6 years ago

Let's hope the gcc developers will fix this. IMO this is the same bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81483

hunt732 commented 3 years ago

Still seems to be present with gcc 8. However you can resolve by changing the format string to "%.2hhX" in the sprintf on line 659.