saitoha / libsixel

A SIXEL encoder/decoder implementation derived from kmiya's sixel (https://github.com/saitoha/sixel).
MIT License
2.46k stars 82 forks source link

Segmentation Fault in sixel_decode_raw_impl at fromsixel.c:585 #111

Closed SuhwanSong closed 4 years ago

SuhwanSong commented 4 years ago

version : img2sixel 1.8.2

There is a Segmentation Fault in sixel_decode_raw_impl at fromsixel.c:585 please run following cmd to reproduce it.

img2sixel -8 $PoC

poc ASAN LOG

=================================================================
==44545==ERROR: AddressSanitizer: SEGV on unknown address 0x610fcf9778de (pc 0x7f468023f320 bp 0x0fffe55645a0 sp 0x7fff2ab22af0 T0)
==44545==The signal is caused by a WRITE memory access.
    #0 0x7f468023f31f in sixel_decode_raw_impl /home/tmp/libsixel/src/fromsixel.c:585:54
    #1 0x7f468025565b in sixel_decode_raw /home/tmp/libsixel/src/fromsixel.c:881:14
    #2 0x7f468035facd in load_sixel /home/tmp/libsixel/src/loader.c:613:14
    #3 0x7f468035facd in load_with_builtin /home/tmp/libsixel/src/loader.c:782
    #4 0x7f468035facd in sixel_helper_load_image_file /home/tmp/libsixel/src/loader.c:1352
    #5 0x7f46805a6d4f in sixel_encoder_encode /home/tmp/libsixel/src/encoder.c:1737:14
    #6 0x51787f in main /home/tmp/libsixel/converters/img2sixel.c:457:22
    #7 0x7f467e909b96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
    #8 0x41a379 in _start (/home/tmp/img2sixel+0x41a379)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/tmp/libsixel/src/fromsixel.c:585:54 in sixel_decode_raw_impl
==44545==ABORTING
saitoha commented 4 years ago

Fixed with 1377517, which prevents integer overflows. Thanks!