-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Description
Programs with JS_Eval that are compiled with -fsanitize=undefined throw an error due to a null pointer being passed to memcpy in this line.
You can replicate using:
#include "quickjs.h"
#include <string.h>
int main() {
JSRuntime* rt = JS_NewRuntime();
JSContext* ctx = JS_NewContext(rt);
const char* str = "1 + 2\0";
JSValue val = JS_Eval(ctx, str, strlen(str), "", 0);
JS_FreeValue(ctx, val);
JS_FreeContext(ctx);
JS_FreeRuntime(rt);
return 0;
}Compiled and called:
CFLAGS="-fsanitize=undefined" make libquickjs.a
gcc -fsanitize=undefined ubsan_test.c libquickjs.a -lm -o ubsan_test
./ubsan_test
Results in:
quickjs.c:33268:13: runtime error: null pointer passed as argument 2, which is declared to never be null
Reproduces on linux (also on debian:sid-slim docker container)
Metadata
Metadata
Assignees
Labels
No labels