author | jdv |
Tue, 09 Aug 2016 13:45:17 +0530 | |
changeset 40432 | 6a878eae7459 |
parent 38152 | 80e5da81fb2c |
child 40631 | ed82623d7831 |
permissions | -rw-r--r-- |
31624
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
1 |
/* |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
4 |
* |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
8 |
* |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
13 |
* accompanied this code). |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
14 |
* |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
18 |
* |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
21 |
* questions. |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
22 |
*/ |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
23 |
|
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
24 |
/* |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
25 |
* @test |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
26 |
* @bug 8129786 |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
27 |
* @summary Verify that JVM correctly processes very long unrecognized VM option |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
28 |
* @library /testlibrary |
38152
80e5da81fb2c
8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents:
31624
diff
changeset
|
29 |
* @modules java.base/jdk.internal.misc |
31624
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
30 |
* @modules java.management |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
31 |
* @run main TestLongUnrecognizedVMOption |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
32 |
*/ |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
33 |
|
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
34 |
import jdk.test.lib.OutputAnalyzer; |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
35 |
import jdk.test.lib.ProcessTools; |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
36 |
|
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
37 |
public class TestLongUnrecognizedVMOption { |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
38 |
|
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
39 |
/* Create option with very long length(greater than 500 characters) */ |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
40 |
private static final String VERY_LONG_OPTION = String.format("%500s=10", "unrecognizedoption").replace(" ", "a"); |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
41 |
|
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
42 |
public static void main(String[] args) throws Exception { |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
43 |
OutputAnalyzer output; |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
44 |
|
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
45 |
output = new OutputAnalyzer(ProcessTools.createJavaProcessBuilder("-XX:" + VERY_LONG_OPTION, "-version").start()); |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
46 |
output.shouldHaveExitValue(1); |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
47 |
output.shouldContain(String.format("Unrecognized VM option '%s'", VERY_LONG_OPTION)); |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
48 |
} |
a184abca1684
8129786: Buffer overrun when passing long not existing option in JDK 9
ddmitriev
parents:
diff
changeset
|
49 |
} |