bug1951874.js (1021B)
1 load(libdir + "wasm-binary.js"); 2 3 let test; 4 assertWarning(() => { 5 test = wasmEvalBinary(moduleWithSections([ 6 sigSection([ 7 { args: [], ret: [] }, 8 ]), 9 declSection([ 10 0, 11 ]), 12 exportSection([ 13 { funcIndex: 0, name: "test" }, 14 ]), 15 bodySection([ 16 funcBody({ locals: [], body: [ 17 UnreachableCode 18 ] }), 19 ]), 20 21 // This name section's contents declare themselves to be one byte longer 22 // than they actually are. This can cause the decoder to read into adjacent 23 // sections. 24 nameSection([ 25 funcNameSubsection([ 26 { name: "1234567", nameLen: 8 }, // should be 7 27 ], 11), // should be 10 28 ]), 29 30 // Without extra bytes at the end of the module, the decoder will EOF 31 // before the name section is finished decoding. 32 customSection("extra"), 33 ])).exports.test; 34 }, /in the 'name' custom section: 1 bytes consumed past the end/); 35 36 try { 37 test(); 38 } catch (e) { 39 print(e.stack); 40 assertEq(e.stack.includes("1234567"), false); 41 }