dmg2img icon indicating copy to clipboard operation
dmg2img copied to clipboard

A Segmentation fault in adc.c:66

Open seviezhou opened this issue 4 years ago • 0 comments

System info

Ubuntu X64, gcc (Ubuntu 5.5.0-12ubuntu1), dmg2img (latest master f16f24)

Command line

./dmg2img -i ./heap-overflow-adc-66 -o /dev/null

Output

decompressing:
opening partition 0 ...                    
Segmentation fault

AddressSanitizer output

decompressing:
opening partition 0 ...                    =================================================================
==29718==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7f66bedfd68c at pc 0x00000040f2dd bp 0x7ffc24807200 sp 0x7ffc248071f0
READ of size 1 at 0x7f66bedfd68c thread T0
    #0 0x40f2dc in memcpy /usr/include/x86_64-linux-gnu/bits/string3.h:53
    #1 0x40f2dc in adc_decompress /home/seviezhou/dmg2img/adc.c:66
    #2 0x405c3e in main /home/seviezhou/dmg2img/dmg2img.c:571
    #3 0x7f66c1fbe83f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
    #4 0x407fe8 in _start (/home/seviezhou/dmg2img/dmg2img+0x407fe8)

0x7f66bedfd68c is located 372 bytes to the left of 1048576-byte region [0x7f66bedfd800,0x7f66beefd800)
allocated by thread T0 here:
    #0 0x7f66c282a602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x403ef0 in main /home/seviezhou/dmg2img/dmg2img.c:371

SUMMARY: AddressSanitizer: heap-buffer-overflow /usr/include/x86_64-linux-gnu/bits/string3.h:53 memcpy
Shadow bytes around the buggy address:
  0x0fed57db7a80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fed57db7a90: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fed57db7aa0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fed57db7ab0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fed57db7ac0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0fed57db7ad0: fa[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fed57db7ae0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fed57db7af0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0fed57db7b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fed57db7b10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0fed57db7b20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
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
==29718==ABORTING

POC

heap-overflow-adc-66.zip

seviezhou avatar Aug 01 '20 13:08 seviezhou