summaryrefslogtreecommitdiffstats
path: root/modules/libjar/test/unit/test_corrupt_1211262.js
blob: c6fc6b2761078c9c0f3f3b00430eaa6f41aaea53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/
 */

// Regression test ensuring that that a STORED entry with differing compressed
// and uncompressed sizes is considered to be corrupt.
function run_test() {
  var file = do_get_file("data/test_corrupt3.zip");

  var zipreader = Cc["@mozilla.org/libjar/zip-reader;1"].createInstance(
    Ci.nsIZipReader
  );
  zipreader.open(file);

  var failed = false;
  for (let entryPath of zipreader.findEntries("*")) {
    let entry = zipreader.getEntry(entryPath);
    if (!entry.isDirectory) {
      try {
        zipreader.getInputStream(entryPath);
      } catch (e) {
        failed = true;
      }
    }
  }

  Assert.ok(failed);
}