Closed swtkiwi closed 6 years ago
I can reproduce it: valgrind messages
Are you sure the crash is in tiv processing code and doesn't originate in the image library used (cimg)? Do you know what's special about the file? Was it just generated by a fuzzer, or is it a specific image test file?
@stefanhaustein It is generated by SAFL,and yes,the crash is in tiv.
What kind of file is that test1 exactly? It seems to be BMP but I couldn't open it. 🤔
00000000: 424d ce47 960a 4393 0000 000a 4393 0000 BM.G..C.....C...
00000010: 000d 4948 0008 0200 0000 00aa 2000 0000 ..IH........ ...
00000020: 0000 0400 0040 0000 0040 0806 0000 04a6 .....@...@......
00000030: 6971 de00 0000 04 iq.....
numbers in little endian 424d: BM ce47 960a: file size in bytes (unreliable), the value is way too big here: 177,620,942 B 4393 0000: reserved, could be all zeroes 000a 4393: offset of image data in bytes from start of file, should be smaller 0000 000d: size of the information block in bytes 4948 0008: image width 0200 0000: image height 00aa: number of colour planes, should always be 1 etc.
@HybridDog I guessed BMP from that 424d
. :D But couldn't open it via any image viewer.
Should not it be a regular picture to be visible via TerminalImageViewer?
The image format is described there: https://de.wikipedia.org/wiki/Windows_Bitmap I've edited my previous post. Some of the values are invalid, this maybe isn't tested by tiv. identify (a command of ImageMagick) shows following:
$ identify test1_tiv
identify-im6.q16: length and filesize do not match `test1_tiv' @ error/bmp.c/ReadBMPImage/825.
identify-im6.q16: static planes value not equal to 1 `test1_tiv' @ error/bmp.c/ReadBMPImage/837.
Edit: there's bmp.c: https://github.com/ImageMagick/ImageMagick/blob/a64a7bcf238a071cedea3fcdf585ec0e94d992bd/coders/bmp.c#L825
The crash seems to be inside cimg_library::CImg
This should be fixed in cimg or the corresponding library that cimg uses to decode bmp.
A heap-buffer-overflow occurred when running ./tiv
And the input file has been put at: https://github.com/fCorleone/fuzz_programs/blob/master/TerminalImageViewer/test1