tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

bug1687243.js (1270B)


      1 let invalidTypedArrays = [
      2    // Uint8Array with invalid length.
      3    [3,0,0,0,0,0,241,255,0,0,0,0,32,0,255,255,3,0,0,0,0,0,0,255,0,0,0,0,31,0,255,255,3,0,0,0,0,0,0,0,1,2,3,0,0,0,0,0,0,0,0,0,0,0,0,0],
      4    // Uint8Array with invalid byteOffset.
      5    [3,0,0,0,0,0,241,255,0,0,0,0,32,0,255,255,3,0,0,0,0,0,0,0,0,0,0,0,31,0,255,255,3,0,0,0,0,0,0,0,1,2,3,0,0,0,0,0,0,0,0,0,0,0,0,1],
      6 ];
      7 let invalidDataViews = [
      8    // DataView with invalid length.
      9    [3,0,0,0,0,0,241,255,0,0,0,0,33,0,255,255,3,0,0,0,0,0,0,255,0,0,0,0,31,0,255,255,3,0,0,0,0,0,0,0,1,2,3,0,0,0,0,0,0,0,0,0,0,0,0,0],
     10    // DataView with invalid byteOffset.
     11    [3,0,0,0,0,0,241,255,0,0,0,0,33,0,255,255,3,0,0,0,0,0,0,0,0,0,0,0,31,0,255,255,3,0,0,0,0,0,0,0,1,2,3,0,0,0,0,0,0,0,0,0,0,0,0,1],
     12 ];
     13 function checkError(data, message) {
     14    let clonebuffer = serialize("dummy");
     15    let buf = new Uint8Array(data);
     16    clonebuffer.clonebuffer = buf.buffer;
     17    let ex = null;
     18    try {
     19        deserialize(clonebuffer);
     20    } catch (e) {
     21        ex = e;
     22    }
     23    assertEq(ex.toString().includes(message), true);
     24 }
     25 for (let data of invalidTypedArrays) {
     26    checkError(data, "invalid typed array length or offset");
     27 }
     28 for (let data of invalidDataViews) {
     29    checkError(data, "invalid DataView length or offset");
     30 }