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

ASan stack-buffer-overflow src/frompnm.c:144 in load_pnm #71

Closed
fgeek opened this issue Jul 19, 2018 · 1 comment
Closed

ASan stack-buffer-overflow src/frompnm.c:144 in load_pnm #71

fgeek opened this issue Jul 19, 2018 · 1 comment
Assignees
Labels

Comments

@fgeek
Copy link

fgeek commented Jul 19, 2018

libsixel-stack-buffer-overflow-frompnm.c-144-load_pnm.png.zip (SHA1: 5cff689656ceb17302920cd64d9a9327a8b41cd4)
Tested commit: 5db717d
Credit: Henri Salo

./bin/img2sixel -o test libsixel-stack-buffer-overflow-frompnm.c-144-load_pnm.png
=================================================================
==27027==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffd6433b3a0 at pc 0x7fe8afc95b44 bp 0x7ffd6433b1b0 sp 0x7ffd6433b1a8
READ of size 1 at 0x7ffd6433b3a0 thread T0
    #0 0x7fe8afc95b43 in load_pnm /home/hsalo/src/libsixel/src/frompnm.c:144
    #1 0x7fe8afc85446 in load_with_builtin /home/hsalo/src/libsixel/src/loader.c:801
    #2 0x7fe8afc927f8 in sixel_helper_load_image_file /home/hsalo/src/libsixel/src/loader.c:1352
    #3 0x7fe8afcb37de in sixel_encoder_encode /home/hsalo/src/libsixel/src/encoder.c:1734
    #4 0x564f3917bbab in main /home/hsalo/src/libsixel/converters/img2sixel.c:457
    #5 0x7fe8aee3a2e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
    #6 0x564f3917bde9 in _start (/home/hsalo/builds/libsixel/5db717dfef6fa327cd4025e7352550f63d20699c/bin/img2sixel+0x2de9)

Address 0x7ffd6433b3a0 is located in stack of thread T0 at offset 352 in frame
    #0 0x7fe8afc92cff in load_pnm /home/hsalo/src/libsixel/src/frompnm.c:64

  This frame has 2 object(s):
    [32, 44) 'component'
    [96, 352) 'tmp' <== Memory access at offset 352 overflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow /home/hsalo/src/libsixel/src/frompnm.c:144 in load_pnm
Shadow bytes around the buggy address:
  0x10002c85f620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10002c85f630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10002c85f640: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 00 04 f4 f4
  0x10002c85f650: f2 f2 f2 f2 00 00 00 00 00 00 00 00 00 00 00 00
  0x10002c85f660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x10002c85f670: 00 00 00 00[f3]f3 f3 f3 00 00 00 00 00 00 00 00
  0x10002c85f680: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
  0x10002c85f690: 04 f4 f4 f4 f2 f2 f2 f2 00 f4 f4 f4 f2 f2 f2 f2
  0x10002c85f6a0: 00 f4 f4 f4 f2 f2 f2 f2 00 f4 f4 f4 f2 f2 f2 f2
  0x10002c85f6b0: 00 f4 f4 f4 f2 f2 f2 f2 00 f4 f4 f4 f2 f2 f2 f2
  0x10002c85f6c0: 00 02 f4 f4 f2 f2 f2 f2 00 00 00 00 f2 f2 f2 f2
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
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==27027==ABORTING
@saitoha saitoha self-assigned this Jul 21, 2018
@saitoha saitoha added the bug label Jul 21, 2018
@saitoha
Copy link
Owner

saitoha commented Jul 21, 2018

@fgeek Thanks for your reporting, I'll release fixes as soon as possible.

saitoha added a commit that referenced this issue Jul 22, 2018
@saitoha saitoha closed this as completed Jul 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants