Skip to content

heap-buffer-overflow in sixel_encode_highcolor at tosixel.c:1338 #113

Description

@SuhwanSong

version : img2sixel 1.8.2

There is a heap-buffer-overflow in sixel_encode_highcolor at tosixel.c:1338
please run following cmd to reproduce it.

img2sixel --high-color $PoC

poc
ASAN LOG

==29035==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000004e11 at pc 0x7fc22c9f8b05 bp 0x7fffb3bda610 sp 0x7fffb3bda608
READ of size 1 at 0x602000004e11 thread T0
    #0 0x7fc22c9f8b04 in sixel_encode_highcolor /home/tmp/libsixel/src/tosixel.c:1338:25
    #1 0x7fc22c9f8b04 in sixel_encode /home/tmp/libsixel/src/tosixel.c:1485
    #2 0x7fc22cd2c8a4 in sixel_encoder_output_without_macro /home/tmp/libsixel/src/encoder.c:820:14
    #3 0x7fc22cd2c8a4 in sixel_encoder_encode_frame /home/tmp/libsixel/src/encoder.c:1050
    #4 0x7fc22cae2d91 in sixel_helper_load_image_file /home/tmp/libsixel/src/loader.c:913:14
    #5 0x7fc22cd24d4f 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 0x7fc22b087b96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
    #8 0x41a379 in _start (/home/tmp/img2sixel+0x41a379)

0x602000004e11 is located 0 bytes to the right of 1-byte region [0x602000004e10,0x602000004e11)
allocated by thread T0 here:
    #0 0x4da230 in __interceptor_malloc (/home/tmp/img2sixel+0x4da230)
    #1 0x7fc22cd2c3ee in sixel_encoder_output_without_macro /home/tmp/libsixel/src/encoder.c:784:26
    #2 0x7fc22cd2c3ee in sixel_encoder_encode_frame /home/tmp/libsixel/src/encoder.c:1050
    #3 0x7fc22cae2d91 in sixel_helper_load_image_file /home/tmp/libsixel/src/loader.c:913:14
    #4 0x7fc22cd24d4f in sixel_encoder_encode /home/tmp/libsixel/src/encoder.c:1737:14
    #5 0x51787f in main /home/tmp/libsixel/converters/img2sixel.c:457:22
    #6 0x7fc22b087b96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/tmp/libsixel/src/tosixel.c:1338:25 in sixel_encode_highcolor
Shadow bytes around the buggy address:
  0x0c047fff8970: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
  0x0c047fff8980: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
  0x0c047fff8990: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
  0x0c047fff89a0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
  0x0c047fff89b0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa 01 fa
=>0x0c047fff89c0: fa fa[01]fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff89d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff89e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff89f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8a00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff8a10: 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
==29035==ABORTING

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions