Corrupt input may lead to crash
Posted: 2017-04-13T16:27:27-07:00
I tried to identify an image, while it was still being saved by scanimage. Instead of either successfully identifying or outputting an error-message, the utility crashed. Using ImageMagick 6.9.6-4 Q16 amd64 2017-03-15 on FreeBSD. According to gdb, the stack is:
With the completed scan ImageMagick has no problems -- identifying, converting, and displaying the image properly. But if the library can crash like this from corrupted input, it can be used to DOS a server or, perhaps, even allow an attacker to break-in by carefully crafting the fake "image" file.
I see no way to attach a file on this site -- please, download the test file from my server.
Please, fix.
Code: Select all
Core was generated by `identify corrupt.png'.
Program terminated with signal SIGABRT, Aborted.
#0 0x0000000803d74b7a in thr_kill () from /lib/libc.so.7
(gdb) where
#0 0x0000000803d74b7a in thr_kill () from /lib/libc.so.7
#1 0x0000000803d74ab6 in raise () from /lib/libc.so.7
#2 0x0000000803d73259 in abort () from /lib/libc.so.7
#3 0x0000000800b1d789 in ?? () from /opt/lib/libMagickCore-6.so.2
#4 0x0000000803a25a3b in ?? () from /lib/libthr.so.3
#5 0x0000000803a2511c in ?? () from /lib/libthr.so.3
#6 <signal handler called>
#7 0x0000000803d74b7a in thr_kill () from /lib/libc.so.7
#8 0x0000000803d74ab6 in raise () from /lib/libc.so.7
#9 0x0000000803d73259 in abort () from /lib/libc.so.7
#10 0x0000000800b1d789 in ?? () from /opt/lib/libMagickCore-6.so.2
#11 0x0000000803a25a3b in ?? () from /lib/libthr.so.3
#12 0x0000000803a2511c in ?? () from /lib/libthr.so.3
#13 <signal handler called>
#14 0x0000000807095228 in ?? () from /opt/lib/ImageMagick-6.9.6/modules-Q16HDRI/coders/pnm.so
#15 0x0000000800a83192 in ReadImage () from /opt/lib/libMagickCore-6.so.2
#16 0x0000000800b96ec0 in ReadStream () from /opt/lib/libMagickCore-6.so.2
#17 0x0000000800a82bee in PingImage () from /opt/lib/libMagickCore-6.so.2
#18 0x0000000800a82e28 in PingImages () from /opt/lib/libMagickCore-6.so.2
#19 0x0000000800f31054 in IdentifyImageCommand () from /opt/lib/libMagickWand-6.so.2
#20 0x0000000800f64f19 in MagickCommandGenesis () from /opt/lib/libMagickWand-6.so.2
#21 0x0000000000400c14 in ?? ()
#22 0x0000000000400adf in ?? ()
#23 0x0000000800622000 in ?? ()
#24 0x0000000000000000 in ?? ()
I see no way to attach a file on this site -- please, download the test file from my server.
Please, fix.