# HG changeset patch # User Omair Majid # Date 1336594140 14400 # Node ID dde230f3536aa4d074be8d87b39b2454b9d2ec12 # Parent 79b3ded39c1f10ffa2b9aa70cb7b573f8cad9d5b PR898: signed applications with big jnlp-file doesn't start diff -r 79b3ded39c1f -r dde230f3536a ChangeLog --- a/ChangeLog Thu Apr 05 12:52:17 2012 +0200 +++ b/ChangeLog Wed May 09 16:09:00 2012 -0400 @@ -1,3 +1,14 @@ +2012-05-09 Omair Majid + + * tests/netx/unit/net/sourceforge/jnlp/JNLPMatcherTest.java + (testIsMatchDoesNotHangOnLargeData): New method. + +2012-05-09 Lars Herschke + + PR898: signed applications with big jnlp-file doesn't start + * netx/net/sourceforge/jnlp/JNLPMatcher.java (JNLPMatcher): Handle large + files correctly. + 2012-04-05 Jiri Vanek Fixing issue when process was not launched at all and when was killed but diff -r 79b3ded39c1f -r dde230f3536a NEWS --- a/NEWS Thu Apr 05 12:52:17 2012 +0200 +++ b/NEWS Wed May 09 16:09:00 2012 -0400 @@ -9,6 +9,8 @@ CVE-XXXX-YYYY: http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=XXXX-YYYY New in release 1.2.1 (2012-XX-XX): +* NetX + - PR898: signed applications with big jnlp-file doesn't start (webstart affect like "frozen") * Plugin - PR895: IcedTea-Web searches for missing classes on each loadClass or findClass diff -r 79b3ded39c1f -r dde230f3536a netx/net/sourceforge/jnlp/JNLPMatcher.java --- a/netx/net/sourceforge/jnlp/JNLPMatcher.java Thu Apr 05 12:52:17 2012 +0200 +++ b/netx/net/sourceforge/jnlp/JNLPMatcher.java Wed May 09 16:09:00 2012 -0400 @@ -38,11 +38,12 @@ package net.sourceforge.jnlp; import java.util.List; +import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; -import java.io.PipedInputStream; -import java.io.PipedOutputStream; +import java.io.Reader; +import java.io.StringReader; import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; @@ -75,7 +76,7 @@ * if IOException, XMLParseException is thrown during parsing; * Or launchJNLP/appTemplate is null */ - public JNLPMatcher(InputStreamReader appTemplate, InputStreamReader launchJNLP, + public JNLPMatcher(Reader appTemplate, Reader launchJNLP, boolean isTemplate) throws JNLPMatcherException { if (appTemplate == null && launchJNLP == null) @@ -87,29 +88,25 @@ throw new JNLPMatcherException("Launching JNLP file is null."); //Declare variables for signed JNLP file - PipedInputStream pinTemplate= null; - PipedOutputStream poutTemplate= null; + ByteArrayOutputStream poutTemplate= null; //Declare variables for launching JNLP file - PipedInputStream pinJNLPFile = null; - PipedOutputStream poutJNLPFile = null; + ByteArrayOutputStream poutJNLPFile = null; try { XMLElement appTemplateXML = new XMLElement(); XMLElement launchJNLPXML = new XMLElement(); // Remove the comments and CDATA from the JNLP file - pinTemplate = new PipedInputStream(); - poutTemplate = new PipedOutputStream(pinTemplate); + poutTemplate = new ByteArrayOutputStream(); appTemplateXML.sanitizeInput(appTemplate, poutTemplate); - pinJNLPFile = new PipedInputStream(); - poutJNLPFile = new PipedOutputStream(pinJNLPFile); + poutJNLPFile = new ByteArrayOutputStream(); launchJNLPXML.sanitizeInput(launchJNLP, poutJNLPFile); // Parse both files - appTemplateXML.parseFromReader(new InputStreamReader(pinTemplate)); - launchJNLPXML.parseFromReader(new InputStreamReader(pinJNLPFile)); + appTemplateXML.parseFromReader(new StringReader(poutTemplate.toString())); + launchJNLPXML.parseFromReader(new StringReader(poutJNLPFile.toString())); // Initialize parent nodes this.appTemplateNode = new Node(appTemplateXML); @@ -122,10 +119,8 @@ e); } finally { // Close all stream - closeInputStream(pinTemplate); closeOutputStream(poutTemplate); - closeInputStream(pinJNLPFile); closeOutputStream(poutJNLPFile); } diff -r 79b3ded39c1f -r dde230f3536a tests/netx/unit/net/sourceforge/jnlp/JNLPMatcherTest.java --- a/tests/netx/unit/net/sourceforge/jnlp/JNLPMatcherTest.java Thu Apr 05 12:52:17 2012 +0200 +++ b/tests/netx/unit/net/sourceforge/jnlp/JNLPMatcherTest.java Wed May 09 16:09:00 2012 -0400 @@ -37,12 +37,13 @@ package net.sourceforge.jnlp; -import static org.junit.Assert.fail; - import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import junit.framework.Assert; +import java.io.StringReader; +import java.util.Random; + +import org.junit.Assert; import org.junit.Test; public class JNLPMatcherTest { @@ -461,4 +462,36 @@ fileReader.close(); launchReader.close(); } + + @Test (timeout=1000 /*ms*/) + public void testIsMatchDoesNotHangOnLargeData() throws JNLPMatcherException { + /* construct an alphabet containing characters 'a' to 'z' */ + final int ALPHABET_SIZE = 26; + char[] alphabet = new char[ALPHABET_SIZE]; + for (int i = 0; i < ALPHABET_SIZE; i++) { + alphabet[i] = (char)('a' + i); + } + /* generate a long but random string using the alphabet */ + final Random r = new Random(); + final int STRING_SIZE = 1024 * 1024; // 1 MB + StringBuilder descriptionBuilder = new StringBuilder(STRING_SIZE); + for (int i = 0; i < STRING_SIZE; i++) { + descriptionBuilder.append(alphabet[r.nextInt(ALPHABET_SIZE)]); + } + String longDescription = descriptionBuilder.toString(); + + String file = + "\n" + + " \n" + + " JNLPMatcher hanges on large file size\n" + + " IcedTea\n" + + " " + longDescription + "\n" + + " \n" + + "\n"; + + StringReader reader1 = new StringReader(file); + StringReader reader2 = new StringReader(file); + JNLPMatcher matcher = new JNLPMatcher(reader1, reader2, false); + Assert.assertTrue(matcher.isMatch()); + } }