File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36250,6 +36250,10 @@ static JSString *JS_ReadString(BCReaderState *s)
3625036250 return NULL;
3625136251 is_wide_char = len & 1;
3625236252 len >>= 1;
36253+ if (len > JS_STRING_LEN_MAX) {
36254+ JS_ThrowInternalError(s->ctx, "string too long");
36255+ return NULL;
36256+ }
3625336257 p = js_alloc_string(s->ctx, len, is_wide_char);
3625436258 if (!p) {
3625536259 s->error_state = -1;
@@ -36361,8 +36365,7 @@ static JSValue JS_ReadBigInt(BCReaderState *s)
3636136365 bc_read_trace(s, "}\n");
3636236366 return __JS_NewShortBigInt(s->ctx, 0);
3636336367 }
36364- p = js_bigint_new(s->ctx,
36365- (len + (JS_LIMB_BITS / 8) - 1) / (JS_LIMB_BITS / 8));
36368+ p = js_bigint_new(s->ctx, (len - 1) / (JS_LIMB_BITS / 8) + 1);
3636636369 if (!p)
3636736370 goto fail;
3636836371 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()
285285function bjson_test_fuzz ( )
286286{
287287 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==" ,
291292 ] ;
292293 for ( var input of corpus ) {
293294 var buf = base64decode ( input ) ;
294295 try {
295296 bjson . read ( buf , 0 , buf . byteLength ) ;
296297 } 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
298299 }
299300 }
300301}
You can’t perform that action at this time.
0 commit comments