diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /netwerk/test/unit/test_bug371473.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/test/unit/test_bug371473.js')
-rw-r--r-- | netwerk/test/unit/test_bug371473.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/netwerk/test/unit/test_bug371473.js b/netwerk/test/unit/test_bug371473.js new file mode 100644 index 0000000000..05ea15aeac --- /dev/null +++ b/netwerk/test/unit/test_bug371473.js @@ -0,0 +1,40 @@ +"use strict"; + +function test_not_too_long() { + var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); + + var spec = "jar:http://example.com/bar.jar!/"; + try { + ios.newURI(spec); + } catch (e) { + do_throw("newURI threw even though it wasn't passed a large nested URI?"); + } +} + +function test_too_long() { + var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); + + var i; + var prefix = "jar:"; + for (i = 0; i < 16; i++) { + prefix = prefix + prefix; + } + var suffix = "!/"; + for (i = 0; i < 16; i++) { + suffix = suffix + suffix; + } + + var spec = prefix + "http://example.com/bar.jar" + suffix; + try { + // The following will produce a recursive call that if + // unchecked would lead to a stack overflow. If we + // do not crash here and thus an exception is caught + // we have passed the test. + ios.newURI(spec); + } catch (e) {} +} + +function run_test() { + test_not_too_long(); + test_too_long(); +} |