File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -36257,6 +36257,10 @@ static JSString *JS_ReadString(BCReaderState *s)
36257
36257
return NULL;
36258
36258
is_wide_char = len & 1;
36259
36259
len >>= 1;
36260
+ if (len > JS_STRING_LEN_MAX) {
36261
+ JS_ThrowInternalError(s->ctx, "string too long");
36262
+ return NULL;
36263
+ }
36260
36264
p = js_alloc_string(s->ctx, len, is_wide_char);
36261
36265
if (!p) {
36262
36266
s->error_state = -1;
@@ -36368,8 +36372,7 @@ static JSValue JS_ReadBigInt(BCReaderState *s)
36368
36372
bc_read_trace(s, "}\n");
36369
36373
return __JS_NewShortBigInt(s->ctx, 0);
36370
36374
}
36371
- p = js_bigint_new(s->ctx,
36372
- (len + (JS_LIMB_BITS / 8) - 1) / (JS_LIMB_BITS / 8));
36375
+ p = js_bigint_new(s->ctx, (len - 1) / (JS_LIMB_BITS / 8) + 1);
36373
36376
if (!p)
36374
36377
goto fail;
36375
36378
for(i = 0; i < len / (JS_LIMB_BITS / 8); i++) {
Original file line number Diff line number Diff line change @@ -285,16 +285,17 @@ function bjson_test_bytecode()
285
285
function bjson_test_fuzz ( )
286
286
{
287
287
var corpus = [
288
- "EBAAAAAABGA=" ,
289
- "EObm5oIt" ,
290
- "EAARABMGBgYGBgYGBgYGBv////8QABEALxH/vy8R/78=" ,
288
+ "FBAAAAAABGA=" ,
289
+ "FObm5oIt" ,
290
+ "FAARABMGBgYGBgYGBgYGBv////8QABEALxH/vy8R/78=" ,
291
+ "FAAIfwAK/////3//////////////////////////////3/8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAD5+fn5+fn5+fn5+fkAAAAAAAYAqw==" ,
291
292
] ;
292
293
for ( var input of corpus ) {
293
294
var buf = base64decode ( input ) ;
294
295
try {
295
296
bjson . read ( buf , 0 , buf . byteLength ) ;
296
297
} catch ( e ) {
297
- // okay, ignore
298
+ if ( / i n v a l i d v e r s i o n / . test ( e . message ) ) throw e ; // corpus needs update
298
299
}
299
300
}
300
301
}
You can’t perform that action at this time.
0 commit comments