Skip to content

Commit eb2ba4f

Browse files
authored
Validate function locals count when deserializing (#1381)
Fixes: #1379
1 parent 610f849 commit eb2ba4f

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

quickjs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38026,6 +38026,10 @@ static JSValue JS_ReadFunctionTag(BCReaderState *s)
3802638026
goto fail;
3802738027
if (bc_get_leb128_int(s, &local_count))
3802838028
goto fail;
38029+
if (local_count < 0 || local_count > JS_MAX_LOCAL_VARS) {
38030+
JS_ThrowSyntaxError(s->ctx, "bad function object");
38031+
goto fail;
38032+
}
3802938033

3803038034
function_size = sizeof(*b);
3803138035
cpool_offset = function_size;

tests/test_bjson.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ function bjson_test_fuzz()
290290
["FwARABMGBgYGBgYGBgYGBv////8QABEALxH/vy8R/78="],
291291
["FwAIfwAK/////3//////////////////////////////3/8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAD5+fn5+fn5+fn5+fkAAAAAAAYAqw=="],
292292
["FwAOAAAAFAA=", bjson.READ_OBJ_REFERENCE],
293+
["FwAMAAAAAAAAAAAAAAAAgICAgAQAAAAA=", bjson.READ_OBJ_BYTECODE],
293294
];
294295
for (var [input, flags] of corpus) {
295296
var buf = base64decode(input);

0 commit comments

Comments
 (0)