lewdlime / abcm2ps

abcm2ps is a command line program which converts ABC to music sheet in PostScript or SVG format. It is an extension of abc2ps which may handle many voices per staff. abcm2ps is Copyright © 2014-2016 Jean-Francois Moine.
http://moinejf.free.fr/
GNU General Public License v3.0
82 stars 31 forks source link

Crash in abcm2ps at buffer.c #104

Closed irfanariq closed 3 years ago

irfanariq commented 3 years ago

Hello,

We are currently working on fuzz testing feature, and we found a crash on abcm2ps.

The stack traces are as follow:

warning: Possible buffer overflow
=================================================================
==616==ERROR: AddressSanitizer: memcpy-param-overlap: memory ranges [0x631000000800,0x6310000105e6) and [0x631000000823, 0x631000010609) overlap
    #0 0x7fa84d5c5425  (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x79425)
    #1 0x55cb9853c8ac in write_buffer .../abcm2ps-git/buffer.c:894
    #2 0x55cb9853b46e in a2b .../abcm2ps-git/buffer.c:749
    #3 0x55cb9856085c in draw_note .../abcm2ps-git/draw.c:1843
    #4 0x55cb9857a1d1 in draw_symbols .../abcm2ps-git/draw.c:4744
    #5 0x55cb9857b211 in draw_all_symb .../abcm2ps-git/draw.c:4866
    #6 0x55cb985b98ae in output_music .../abcm2ps-git/music.c:5120
    #7 0x55cb985c089a in generate .../abcm2ps-git/parse.c:1042
    #8 0x55cb985c0c22 in gen_ly .../abcm2ps-git/parse.c:1063
    #9 0x55cb985ce717 in get_info .../abcm2ps-git/parse.c:3057
    #10 0x55cb985d2815 in do_tune .../abcm2ps-git/parse.c:3510
    #11 0x55cb98523d60 in abc_eof .../abcm2ps-git/abcparse.c:202
    #12 0x55cb9858c9f7 in frontend .../abcm2ps-git/front.c:906
    #13 0x55cb98520154 in treat_file .../abcm2ps-git/abcm2ps.c:240
    #14 0x55cb98520272 in treat_abc_file .../abcm2ps-git/abcm2ps.c:283
    #15 0x55cb98522d45 in main .../abcm2ps-git/abcm2ps.c:1041

Here is the full stack trace : stacktrace_abcm2ps_3.zip

Step to reproduce

We configured abcm2ps using CFLAGS="-g -O0 -fsanitize=address" LDFLAGS="-g -O0 -fsanitize=address" ./configure --disable-shared and built in using make -j10; make install, and run it with:

./abcm2ps <attached file> -O /dev/null

Attachment: input_abcm2ps_3.zip

Environment

Thank you.

moinejf commented 3 years ago

The problem should be fixed by the commit d880797.

irfanariq commented 3 years ago

Yes, I have tried and the problem did not occur anymore. I will close the issue.