miniupnp / ngiflib

GIF picture format decoding library written in C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

heap-buffer-overflow at WritePixels() in ngiflib.c:213

Marsman1996 opened this issue · comments

Tested in Ubuntu 16.04, 64bit, ngiflib(master 3bb9980)

Triggered by
$ gif2tga $POC

POC file:
https://github.com/Marsman1996/pocs/blob/master/ngiflib/poc14-WritePixels-heapoverflow

ASAN info:

==122092==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6150000002a0 at pc 0x55f220dc8d87 bp 0x7ffeb9b2bb80 sp 0x7ffeb9b2bb70
WRITE of size 4 at 0x6150000002a0 thread T0
    #0 0x55f220dc8d86 in WritePixels /home/ubuntu/Desktop/crashana/ngiflib/ngiflib/ngiflib.c:213
    #1 0x55f220dcb5d1 in DecodeGifImg /home/ubuntu/Desktop/crashana/ngiflib/ngiflib/ngiflib.c:568
    #2 0x55f220dcce3b in LoadGif /home/ubuntu/Desktop/crashana/ngiflib/ngiflib/ngiflib.c:809
    #3 0x55f220dc7dc4 in main /home/ubuntu/Desktop/crashana/ngiflib/ngiflib/gif2tga.c:95
    #4 0x7f1dcc2b9b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
    #5 0x55f220dc7169 in _start (/home/ubuntu/Desktop/crashana/ngiflib/ngiflib/gif2tga+0x2169)

Address 0x6150000002a0 is a wild pointer.
SUMMARY: AddressSanitizer: heap-buffer-overflow /home/ubuntu/Desktop/crashana/ngiflib/ngiflib/ngiflib.c:213 in WritePixels
Shadow bytes around the buggy address:
  0x0c2a7fff8000: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2a7fff8010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c2a7fff8020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c2a7fff8030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c2a7fff8040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c2a7fff8050: fa fa fa fa[fa]fa fa fa fa fa fa fa fa fa fa fa
  0x0c2a7fff8060: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2a7fff8070: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2a7fff8080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2a7fff8090: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2a7fff80a0: 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
==122092==ABORTING