forked from quickjs-ng/quickjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix crash in deserializer (quickjs-ng#602)
Check inside the deserializer that const atoms are indeed const, don't trust the input. The serializer only writes type 0 records for const atoms but the byte stream may have been corrupted or manipulated. Overlooked during review of c25aad7 ("Add ability to (de)serialize symbols") Found with libfuzzer and it found it _really_ fast. Great tool.
- Loading branch information
1 parent
e4406fa
commit a1d1bce
Showing
5 changed files
with
89 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ build/ | |
unicode/ | ||
test262_*.txt | ||
.idea | ||
cmake-* | ||
cmake-* | ||
fuzz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// clang -g -O1 -fsanitize=fuzzer -o fuzz fuzz.c | ||
#include "quickjs.h" | ||
#include "quickjs.c" | ||
#include "cutils.c" | ||
#include "libbf.c" | ||
#include "libregexp.c" | ||
#include "libunicode.c" | ||
#include <stdlib.h> | ||
|
||
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) | ||
{ | ||
JSRuntime *rt = JS_NewRuntime(); | ||
if (!rt) | ||
exit(1); | ||
JSContext *ctx = JS_NewContext(rt); | ||
if (!ctx) | ||
exit(1); | ||
JSValueConst val = JS_ReadObject(ctx, buf, len, /*flags*/0); | ||
JS_FreeValue(ctx, val); | ||
JS_FreeContext(ctx); | ||
JS_FreeRuntime(rt); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters