This bug was found while fuzzing graphicsmagick with afl-fuzz
Tested on hg changeset 44ed8318ba6a+
Command: gm convert id:000222,sig:06,src:005903+005149,op:splice,rep:16 /dev/null
=================================================================
==18729==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xb5f6edc0 at pc 0x0836af3e bp 0xbfe0dbd8 sp 0xbfe0dbd0
WRITE of size 1 at 0xb5f6edc0 thread T0
#0 0x836af3d in MagickStrlCat /home/user/Desktop/graphicsmagick/magick/utility.c:4353:2
#1 0x836af3d in GetPageGeometry /home/user/Desktop/graphicsmagick/magick/utility.c:2293
#2 0x8440ab3 in ReadMIFFImage /home/user/Desktop/graphicsmagick/coders/miff.c:1147:30
#3 0x81f84b4 in ReadImage /home/user/Desktop/graphicsmagick/magick/constitute.c:1607:14
#4 0x816fbca in ConvertImageCommand /home/user/Desktop/graphicsmagick/magick/command.c:4348:22
#5 0x8187f6b in MagickCommand /home/user/Desktop/graphicsmagick/magick/command.c:8862:27
#6 0x81cd999 in GMCommandSingle /home/user/Desktop/graphicsmagick/magick/command.c:17338:10
#7 0x81cc6ae in GMCommand /home/user/Desktop/graphicsmagick/magick/command.c:17391:16
#8 0x8139511 in main /home/user/Desktop/graphicsmagick/utilities/gm.c:61:10
#9 0xb748b73d in __libc_start_main /build/glibc-tVsQx_/glibc-2.21/csu/libc-start.c:289
#10 0x807fd9b in _start (/home/user/Desktop/graphicsmagick/utilities/gm+0x807fd9b)
0xb5f6edc0 is located 0 bytes to the right of 256-byte region [0xb5f6ecc0,0xb5f6edc0)
allocated by thread T0 here:
#0 0x8117a29 in malloc (/home/user/Desktop/graphicsmagick/utilities/gm+0x8117a29)
#1 0x827e984 in MagickMalloc /home/user/Desktop/graphicsmagick/magick/memory.c:156:11
#2 0x8440ab3 in ReadMIFFImage /home/user/Desktop/graphicsmagick/coders/miff.c:1147:30
#3 0x81f84b4 in ReadImage /home/user/Desktop/graphicsmagick/magick/constitute.c:1607:14
#4 0x816fbca in ConvertImageCommand /home/user/Desktop/graphicsmagick/magick/command.c:4348:22
#5 0x8187f6b in MagickCommand /home/user/Desktop/graphicsmagick/magick/command.c:8862:27
#6 0x81cd999 in GMCommandSingle /home/user/Desktop/graphicsmagick/magick/command.c:17338:10
#7 0x81cc6ae in GMCommand /home/user/Desktop/graphicsmagick/magick/command.c:17391:16
#8 0x8139511 in main /home/user/Desktop/graphicsmagick/utilities/gm.c:61:10
SUMMARY: AddressSanitizer: heap-buffer-overflow /home/user/Desktop/graphicsmagick/magick/utility.c:4353 MagickStrlCat
Shadow bytes around the buggy address:
0x36bedd60: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x36bedd70: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x36bedd80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x36bedd90: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
0x36bedda0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x36beddb0: 00 00 00 00 00 00 00 00[fa]fa fa fa fa fa fa fa
0x36beddc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x36beddd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x36bedde0: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
0x36beddf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x36bede00: 00 00 00 00 00 00 00 00 fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Heap right redzone: fb
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack partial redzone: f4
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==18729==ABORTING
Diff:
This problem is also fixed by Mercurial changeset 14747:4091df6e035d