changeset 11081:d25cd41aaa32

Merge
author kcr
date Fri, 04 May 2018 11:53:16 -0700
parents 3f02576411b8 4aadef9a59fd
children c05f5aa48552
files
diffstat 6 files changed, 154 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.media/src/main/native/gstreamer/gstreamer-lite/gst-plugins-bad/gst/aiff/aiffparse.c	Fri May 04 11:48:24 2018 -0700
+++ b/modules/javafx.media/src/main/native/gstreamer/gstreamer-lite/gst-plugins-bad/gst/aiff/aiffparse.c	Fri May 04 11:53:16 2018 -0700
@@ -1278,6 +1278,14 @@
   if (desired >= aiff->bytes_per_sample)
     desired -= (desired % aiff->bytes_per_sample);
 
+#ifdef GSTREAMER_LITE
+  if (desired == 0) {
+    GST_ELEMENT_ERROR (aiff, STREAM, DEMUX, (NULL),
+              ("Invalid stream"));
+    return GST_FLOW_ERROR;
+  }
+#endif // GSTREAMER_LITE
+
   GST_LOG_OBJECT (aiff, "Fetching %" G_GINT64_FORMAT " bytes of data "
       "from the sinkpad", desired);
 
--- a/modules/javafx.media/src/main/native/gstreamer/gstreamer-lite/gst-plugins-good/gst/wavparse/gstwavparse.c	Fri May 04 11:48:24 2018 -0700
+++ b/modules/javafx.media/src/main/native/gstreamer/gstreamer-lite/gst-plugins-good/gst/wavparse/gstwavparse.c	Fri May 04 11:53:16 2018 -0700
@@ -1955,6 +1955,14 @@
   if (desired >= wav->blockalign && wav->blockalign > 0)
     desired -= (desired % wav->blockalign);
 
+#ifdef GSTREAMER_LITE
+  if (desired == 0) {
+    GST_ELEMENT_ERROR (wav, STREAM, DEMUX, (NULL),
+              ("Invalid stream"));
+    return GST_FLOW_ERROR;
+  }
+#endif // GSTREAMER_LITE
+
   GST_LOG_OBJECT (wav, "Fetching %" G_GINT64_FORMAT " bytes of data "
       "from the sinkpad", desired);
 
--- a/modules/jdk.packager/src/main/java/com/sun/javafx/tools/packager/DeployParams.java	Fri May 04 11:48:24 2018 -0700
+++ b/modules/jdk.packager/src/main/java/com/sun/javafx/tools/packager/DeployParams.java	Fri May 04 11:53:16 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -495,6 +495,39 @@
                       path);
     }
 
+    public static void validateAppName(String s) throws PackagerException {
+        if (s == null || s.length() == 0) {
+            // empty or null string - there is no unsupported char
+            return;
+        }
+        int last = s.length() - 1;
+
+        char fc = s.charAt(0);
+        char lc = s.charAt(last);
+
+        // illegal to end in backslash escape char
+        if (lc == '\\') {
+            throw new PackagerException("ERR_InvalidCharacterInArgument", "-name");
+        }
+
+        for (int i = 0; i < s.length(); i++) {
+            char a = s.charAt(i);
+            // We check for ASCII codes first which we accept. If check fails,
+            // then check if it is acceptable extended ASCII or unicode character.
+            if (a < ' ' || a > '~' || a == '%') {
+                // Reject '%', whitespaces and ISO Control.
+                // Accept anything else including special characters like copyright
+                // symbols. Note: space will be included by ASCII check above,
+                // but other whitespace like tabs or new line will be ignored.
+                if (Character.isISOControl(a) || Character.isWhitespace(a) || a == '%') {
+                    throw new PackagerException("ERR_InvalidCharacterInArgument", "-name");
+                }
+            }
+            if (a == '"') {
+                throw new PackagerException("ERR_InvalidCharacterInArgument", "-name");
+            }
+        }
+    }
 
     @Override
     public void validate() throws PackagerException {
@@ -514,6 +547,7 @@
                 throw new PackagerException("ERR_MissingArgument", "-appclass");
             }
         }
+        validateAppName(appName);
     }
 
     public boolean validateForJNLP() {
--- a/modules/jdk.packager/src/main/java/com/sun/javafx/tools/packager/MakeAllParams.java	Fri May 04 11:48:24 2018 -0700
+++ b/modules/jdk.packager/src/main/java/com/sun/javafx/tools/packager/MakeAllParams.java	Fri May 04 11:53:16 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -67,5 +67,6 @@
     }
 
     public void validate() throws PackagerException {
+        DeployParams.validateAppName(appName);
     }
 }
--- a/modules/jdk.packager/src/main/resources/com/sun/javafx/tools/packager/Bundle.properties	Fri May 04 11:48:24 2018 -0700
+++ b/modules/jdk.packager/src/main/resources/com/sun/javafx/tools/packager/Bundle.properties	Fri May 04 11:53:16 2018 -0700
@@ -207,6 +207,7 @@
 ERR_SignFailed=Error: Signing failed
 ERR_MissingAppResources=Error: No application jars found
 ERR_NoEmbeddedDT=Error: -includedt requires the java deployment toolkit, which is not included in this distribution
+ERR_InvalidCharacterInArgument=Error: Invalid character found in {0} argument
 
 MSG_UpdatingJar=Updating jar file\: {0}
 MSG_NoJREPackaged=Package is configured to ship without a JRE.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/jdk.packager/src/test/java/com/sun/javafx/tools/packager/DeployParamsTest.java	Fri May 04 11:53:16 2018 -0700
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.javafx.tools.packager;
+
+import java.io.File;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.junit.After;
+
+public class DeployParamsTest {
+
+    private File testRoot = null;
+
+    @Before
+    public void setUp() {
+        testRoot = new File("build/tmp/tests/deployParamsTest");
+        testRoot.mkdirs();
+    }
+
+    @After
+    public void tearDown() {
+        if (testRoot != null) {
+            testRoot.delete();
+        }
+    }
+
+    @Test
+    public void testValidateAppName1() throws PackagerException {
+        DeployParams params = getParamsAppName();
+
+        params.setAppName("Test");
+        params.validate();
+
+        params.setAppName("Test Name");
+        params.validate();
+
+        params.setAppName("Test - Name !!!");
+        params.validate();
+    }
+
+    @Test
+    public void testValidateAppName2() throws PackagerException {
+        DeployParams params = getParamsAppName();
+
+        params.setAppName("Test\nName");
+        appName2TestHelper(params);
+
+        params.setAppName("Test\rName");
+        appName2TestHelper(params);
+
+        params.setAppName("TestName\\");
+        appName2TestHelper(params);
+
+        params.setAppName("Test \" Name");
+        appName2TestHelper(params);
+    }
+
+    private void appName2TestHelper(DeployParams params) {
+        try {
+            params.validate();
+            fail("An exception should have been thrown");
+        } catch (PackagerException pe) { }
+    }
+
+    // Returns deploy params initialized to pass all validation, except for
+    // app name
+    private DeployParams getParamsAppName() {
+        DeployParams params = new DeployParams();
+        params.setOutdir(testRoot);
+        params.setOutfile("Test");
+        params.addResource(testRoot, new File(testRoot, "test.jar"));
+        params.setApplicationClass("TestClass");
+        return params;
+    }
+
+}