Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
SuhwanSong opened this issue Dec 13, 2019 · 1 comment
Closed

Comments

@SuhwanSong
Copy link

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
@saitoha
Copy link
Owner

saitoha commented Dec 16, 2019

It seems to be fixed with #93. Thanks!

@saitoha saitoha closed this as completed Dec 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants