Menu

#458 Heap out of bounds read in ReadRLEImage()

v1.0_(example)
closed-fixed
None
5
2017-09-24
2017-09-13
No

After some fuzz testing I found a crashing test case.

Changeset: 15166:e8048eade0e6

Command: gm convert -negate -clip gm_hoobr_ReadRLEImage /dev/null

ASAN:

==7513==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x616000000ee0 at pc 0x00000089f47e bp 0x7fff3ebe1db0 sp 0x7fff3ebe1da8
READ of size 1 at 0x616000000ee0 thread T0
    #0 0x89f47d in ReadRLEImage XYZ/GM/coders/rle.c:753:25
    #1 0x595069 in ReadImage XYZ/GM/magick/constitute.c:1607:13
    #2 0x51a1e0 in ConvertImageCommand XYZ/GM/magick/command.c:4348:22
    #3 0x52fd21 in MagickCommand XYZ/GM/magick/command.c:8869:17
    #4 0x567983 in GMCommandSingle XYZ/GM/magick/command.c:17396:10
    #5 0x566683 in GMCommand XYZ/GM/magick/command.c:17449:16
    #6 0x7fdb5a87b82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
    #7 0x41beb8 in _start (/usr/local/bin/gm+0x41beb8)

0x616000000ee0 is located 0 bytes to the right of 608-byte region [0x616000000c80,0x616000000ee0)
allocated by thread T0 here:
    #0 0x4c2bbc in __interceptor_malloc /scratch/llvm/clang-4/xenial/final/llvm.src/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:66:3
    #1 0x61e7d6 in MagickMalloc XYZ/GM/magick/memory.c:156:10
    #2 0x61e7d6 in MagickMallocArray XYZ/GM/magick/memory.c:347
    #3 0x595069 in ReadImage XYZ/GM/magick/constitute.c:1607:13
    #4 0x51a1e0 in ConvertImageCommand XYZ/GM/magick/command.c:4348:22
    #5 0x52fd21 in MagickCommand XYZ/GM/magick/command.c:8869:17
    #6 0x567983 in GMCommandSingle XYZ/GM/magick/command.c:17396:10
    #7 0x566683 in GMCommand XYZ/GM/magick/command.c:17449:16
    #8 0x7fdb5a87b82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)

SUMMARY: AddressSanitizer: heap-buffer-overflow XYZ/GM/coders/rle.c:753:25 in ReadRLEImage
Shadow bytes around the buggy address:
  0x0c2c7fff8180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2c7fff8190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c2c7fff81a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c2c7fff81b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c2c7fff81c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c2c7fff81d0: 00 00 00 00 00 00 00 00 00 00 00 00[fa]fa fa fa
  0x0c2c7fff81e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2c7fff81f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2c7fff8200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2c7fff8210: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2c7fff8220: fa fa fa fa fa fa fa fa 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
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  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
==7513==ABORTING
1 Attachments

Discussion

  • Bob Friesenhahn

    Bob Friesenhahn - 2017-09-13
    • assigned_to: Bob Friesenhahn
     
  • Bob Friesenhahn

    Bob Friesenhahn - 2017-09-24
    • status: open --> closed-fixed
     
  • Bob Friesenhahn

    Bob Friesenhahn - 2017-09-24

    This problem is fixed by Mercurial changeset 15177:5381c71724e3. Thanks for the report!

     

Log in to post a comment.