cesanta / mjs

Embedded JavaScript engine for C/C++
https://mongoose-os.com
Other
1.84k stars 171 forks source link

SEGV /mjs/mjs.c:7347:3 in mjs_get_mjs #268

Open Vincebye opened 3 months ago

Vincebye commented 3 months ago

Environment

Ubuntu 22.04.3 LTS

Affected Version

MJS 2.20.0

Step to reproduce

cd mjs 
git checkout b1b6eac6b1e5b830a5cb14f8f4dc690ef3162551 
export LDFLAGS="-lpthread -latomic" 
./afl-clang -DMJS_MAIN mjs.c -fno-inline -ldl -o mjs-bin -fsanitize=address -g 
./mjs-bin -f poc.js 

Contents of PoCfile

die--;
die(1);

ASAN Report

$ ./mjs-bin poc5.js
AddressSanitizer:DEADLYSIGNAL
=================================================================
==29364==ERROR: AddressSanitizer: SEGV on unknown address 0x5608ec91b48c (pc 0x5608ec91b4ff bp 0x7ffed0055e70 sp 0x7ffed0055b58 T0)
==29364==The signal is caused by a WRITE memory access.
    #0 0x5608ec91b4ff in mjs_get_mjs /home/v/jse/mjs/mjs.c:7347:3
    #1 0x5608ec930408 in mjs_execute /home/v/jse/mjs/mjs.c:8824:11
    #2 0x5608ec9254d4 in mjs_exec_internal /home/v/jse/mjs/mjs.c:9044:5
    #3 0x5608ec925cb3 in mjs_exec_file /home/v/jse/mjs/mjs.c:9067:11
    #4 0x5608ec9375e8 in main /home/v/jse/mjs/mjs.c:11423:11
    #5 0x7fc11f007d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #6 0x7fc11f007e3f in __libc_start_main csu/../csu/libc-start.c:392:3
    #7 0x5608ec8093d4 in _start (/home/v/jse/mjs/mjs-bin+0x283d4)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/v/jse/mjs/mjs.c:7347:3 in mjs_get_mjs
==29364==ABORTING