[libbluray-devel] [Git][videolan/libbluray][master] 6 commits: Silence coverity unguarded read warning

Petri Hintukainen gitlab at videolan.org
Sat Feb 23 19:06:23 CET 2019


Petri Hintukainen pushed to branch master at VideoLAN / libbluray


Commits:
1c962b55 by hpi1 at 2019-02-23T15:01:39Z
Silence coverity unguarded read warning

- - - - -
a05d9b5e by hpi1 at 2019-02-23T15:02:04Z
Fix using default encoding

- - - - -
1b9c2401 by hpi1 at 2019-02-23T15:02:23Z
Fix type before cast

- - - - -
fc1e71de by hpi1 at 2019-02-23T15:02:38Z
Simplify

- - - - -
2fb71f4e by hpi1 at 2019-02-23T17:38:25Z
Use doPrivileged when creating class loader

- - - - -
f1a41a90 by hpi1 at 2019-02-23T17:38:25Z
Make implementation class package private

- - - - -


7 changed files:

- src/libbluray/bdj/java-j2se/java/awt/BDToolkit.java
- src/libbluray/bdj/java-j2se/java/awt/peer/BDFramePeer.java
- src/libbluray/bdj/java-j2se/java/io/FileInputStream.java
- src/libbluray/bdj/java/org/dvb/lang/DVBClassLoader.java
- src/libbluray/bdj/java/org/dvb/lang/DVBClassLoaderImpl.java
- src/libbluray/bdj/java/org/videolan/BDJClassLoader.java
- src/libbluray/bdj/java/org/videolan/mmbd/LoaderAdapter.java


Changes:

=====================================
src/libbluray/bdj/java-j2se/java/awt/BDToolkit.java
=====================================
@@ -88,7 +88,11 @@ public class BDToolkit extends BDToolkitBase
         throw new Error("Not implemented");
     }
     public java.awt.peer.FramePeer createFrame(Frame target) {
-        return new BDFramePeer(target, (BDRootWindow)target);
+        if (!(target instanceof BDRootWindow)) {
+            logger.error("createFrame(): not BDRootWindow");
+            throw new Error("Not implemented");
+        }
+        return new BDFramePeer((BDRootWindow)target);
     }
 
     public java.awt.peer.ButtonPeer createButton(Button target) {


=====================================
src/libbluray/bdj/java-j2se/java/awt/peer/BDFramePeer.java
=====================================
@@ -30,8 +30,8 @@ import org.videolan.Logger;
 
 public class BDFramePeer extends BDComponentPeer implements FramePeer
 {
-    public BDFramePeer(Frame frame, BDRootWindow rootWindow) {
-        super(frame.getToolkit(), frame);
+    public BDFramePeer(BDRootWindow rootWindow) {
+        super(rootWindow.getToolkit(), rootWindow);
         this.rootWindow = rootWindow;
     }
 


=====================================
src/libbluray/bdj/java-j2se/java/io/FileInputStream.java
=====================================
@@ -177,8 +177,8 @@ public class FileInputStream extends InputStream
             if (logger == null) {
                 logger = Logger.getLogger(FileInputStream.class.getName());
             }
+            return logger;
         }
-        return logger;
     }
 
     private static native void initIDs();


=====================================
src/libbluray/bdj/java/org/dvb/lang/DVBClassLoader.java
=====================================
@@ -26,28 +26,51 @@ import java.security.PermissionCollection;
 import java.util.Enumeration;
 import java.util.jar.Manifest;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
 public abstract class DVBClassLoader extends java.security.SecureClassLoader {
-    public static DVBClassLoader newInstance(URL[] urls) {
-        return new DVBClassLoaderImpl(urls);
+    public static DVBClassLoader newInstance(final URL[] urls) {
+        return (DVBClassLoader)AccessController.doPrivileged(
+            new PrivilegedAction() {
+                   public Object run() {
+                       return new DVBClassLoaderImpl(urls);
+                   }
+            });
     }
 
-    public static DVBClassLoader newInstance(URL[] urls, ClassLoader parent) {
-        return new DVBClassLoaderImpl(urls, parent);
+    public static DVBClassLoader newInstance(final URL[] urls, final ClassLoader parent) {
+        return (DVBClassLoader)AccessController.doPrivileged(
+            new PrivilegedAction() {
+                public Object run() {
+                    return new DVBClassLoaderImpl(urls, parent);
+                }
+            });
     }
 
-    public DVBClassLoader(URL[] urls) {
+    public DVBClassLoader(final URL[] urls) {
         SecurityManager sm = System.getSecurityManager();
         if (sm != null)
             sm.checkCreateClassLoader();
-        loader = new DVBURLClassLoader(urls);
+        loader = (DVBURLClassLoader)AccessController.doPrivileged(
+            new PrivilegedAction() {
+                public Object run() {
+                    return new DVBURLClassLoader(urls);
+                }
+            });
     }
 
-    public DVBClassLoader(URL[] urls, ClassLoader parent) {
+    public DVBClassLoader(final URL[] urls, final ClassLoader parent) {
         super(parent);
         SecurityManager sm = System.getSecurityManager();
         if (sm != null)
             sm.checkCreateClassLoader();
-        loader = new DVBURLClassLoader(urls, parent);
+        loader = (DVBURLClassLoader)AccessController.doPrivileged(
+            new PrivilegedAction() {
+                public Object run() {
+                    return new DVBURLClassLoader(urls, parent);
+                }
+            });
     }
 
     public Class findClass(String name) throws ClassNotFoundException {


=====================================
src/libbluray/bdj/java/org/dvb/lang/DVBClassLoaderImpl.java
=====================================
@@ -21,7 +21,7 @@ package org.dvb.lang;
 
 import java.net.URL;
 
-public class DVBClassLoaderImpl extends DVBClassLoader {
+class DVBClassLoaderImpl extends DVBClassLoader {
     public DVBClassLoaderImpl(URL[] urls) {
         super(urls);
     }


=====================================
src/libbluray/bdj/java/org/videolan/BDJClassLoader.java
=====================================
@@ -31,12 +31,15 @@ import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.Map;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
 import javax.tv.xlet.Xlet;
 
 import org.videolan.bdjo.AppCache;
 
 public class BDJClassLoader extends URLClassLoader {
-    public static BDJClassLoader newInstance(AppCache[] appCaches, String basePath, String classPathExt, String xletClass) {
+    public static BDJClassLoader newInstance(AppCache[] appCaches, String basePath, String classPathExt, final String xletClass) {
         ArrayList classPath = new ArrayList();
         URL url = translateClassPath(appCaches, basePath, null);
         if (url != null)
@@ -47,7 +50,14 @@ public class BDJClassLoader extends URLClassLoader {
             if ((url != null) && (classPath.indexOf(url) < 0))
                 classPath.add(url);
         }
-        return new BDJClassLoader((URL[])classPath.toArray(new URL[classPath.size()]) , xletClass);
+
+        final URL[] urls = (URL[])classPath.toArray(new URL[classPath.size()]);
+        return (BDJClassLoader)AccessController.doPrivileged(
+                new PrivilegedAction() {
+                    public Object run() {
+                        return new BDJClassLoader(urls, xletClass);
+                    }
+                });
     }
 
     private static URL translateClassPath(AppCache[] appCaches, String basePath, String classPath) {


=====================================
src/libbluray/bdj/java/org/videolan/mmbd/LoaderAdapter.java
=====================================
@@ -60,17 +60,22 @@ public class LoaderAdapter implements BDJLoaderAdapter {
         if (title != 65535)
             return in;
 
+        try {
         for (i1 = 0; i1 < in.length; i1++) {
             if (in[i1].getParams() != null &&
                 in[i1].getParams().length == 1 &&
                 in[i1].getControlCode() == AppEntry.AUTOSTART &&
-                match(in[i1].getInitialClass().getBytes(),0,0) == 0 &&
-                match(in[i1].getParams()[0].substring(0,9).getBytes(),1,0) == 0) {
+                match(in[i1].getInitialClass().getBytes("UTF-8"),0,0) == 0 &&
+                match(in[i1].getParams()[0].substring(0,9).getBytes("UTF-8"),1,0) == 0) {
                 break;
             }
         }
         if (i1 == in.length)
             return in;
+        } catch (java.io.UnsupportedEncodingException uee) {
+            logger.error("" + uee);
+            return in;
+        }
 
         xlet = "." + StrUtil.split(in[i1].getParams()[0], ':')[1];
         for (i2 = 0; i2 < in.length; i2++) {



View it on GitLab: https://code.videolan.org/videolan/libbluray/compare/8d1179408c434b36e9ada25a12d655c27b05c4d4...f1a41a906efef13c604a5ebd57165c8668da8e55

-- 
View it on GitLab: https://code.videolan.org/videolan/libbluray/compare/8d1179408c434b36e9ada25a12d655c27b05c4d4...f1a41a906efef13c604a5ebd57165c8668da8e55
You're receiving this email because of your account on code.videolan.org.


More information about the libbluray-devel mailing list