[libbluray-devel] [Git][videolan/libbluray][master] 6 commits: Fix creating BDGraphicsEnvironment in Java 10

Petri Hintukainen gitlab at videolan.org
Thu Jan 3 22:18:32 CET 2019


Petri Hintukainen pushed to branch master at VideoLAN / libbluray


Commits:
c289eac1 by hpi1 at 2019-01-02T23:06:41Z
Fix creating BDGraphicsEnvironment in Java 10

java.lang.Error: Could not instantiate Graphics Environment: java.awt.BDGraphicsEnvironment
java.desktop/java.awt.GraphicsEnvironment$LocalGE.createGE(GraphicsEnvironment.java:117)

- - - - -
d8cb3322 by hpi1 at 2019-01-03T20:31:11Z
Check for privileged context

- - - - -
43dae4d2 by hpi1 at 2019-01-03T20:54:42Z
Fix broken BD-J app tables

- - - - -
e51fa05f by hpi1 at 2019-01-03T21:02:35Z
BDGraphics: delay default font creation

Fixes bootstrap issues

- - - - -
6d45ee0c by hpi1 at 2019-01-03T21:12:16Z
Simplify

- - - - -
98a7d60a by hpi1 at 2019-01-03T21:14:37Z
Validate TextST sub path id (fix possible OOB read)

- - - - -


5 changed files:

- src/libbluray/bdj/java/java/awt/BDGraphicsBase.java
- src/libbluray/bdj/java/java/awt/BDGraphicsEnvironment.java
- src/libbluray/bdj/java/org/videolan/mmbd/Adapter.java
- + src/libbluray/bdj/java/org/videolan/mmbd/LoaderAdapter.java
- src/libbluray/bluray.c


Changes:

=====================================
src/libbluray/bdj/java/java/awt/BDGraphicsBase.java
=====================================
@@ -42,7 +42,7 @@ import org.videolan.Logger;
 
 abstract class BDGraphicsBase extends DVBGraphics implements ConstrainableGraphics {
     private static final Color DEFAULT_COLOR = Color.BLACK;
-    private static final Font DEFAULT_FONT = new Font("Dialog", Font.PLAIN, 12);
+    private static Font DEFAULT_FONT;
 
     private int width;
     private int height;
@@ -126,6 +126,12 @@ abstract class BDGraphicsBase extends DVBGraphics implements ConstrainableGraphi
         postInit();
     }
 
+    private static Font getDefaultFont() {
+        if (DEFAULT_FONT == null)
+            DEFAULT_FONT = new Font("Dialog", Font.PLAIN, 12);
+        return DEFAULT_FONT;
+    }
+
     private void postInit() {
         if (foreground == null)
             foreground = DEFAULT_COLOR;
@@ -136,7 +142,7 @@ abstract class BDGraphicsBase extends DVBGraphics implements ConstrainableGraphi
         if (font == null) {
             font = GUIManager.getInstance().getDefaultFont();
             if (font == null) {
-                font = DEFAULT_FONT;
+                font = getDefaultFont();
             }
         }
         fontMetrics = null;
@@ -209,7 +215,7 @@ abstract class BDGraphicsBase extends DVBGraphics implements ConstrainableGraphi
 
     public Font getFont() {
         if (font == null)
-            return DEFAULT_FONT;
+            return getDefaultFont();
         return font;
     }
 


=====================================
src/libbluray/bdj/java/java/awt/BDGraphicsEnvironment.java
=====================================
@@ -27,7 +27,7 @@ import org.videolan.Logger;
 class BDGraphicsEnvironment extends GraphicsEnvironment {
     private BDGraphicsDevice graphicsDevice;
 
-    BDGraphicsEnvironment() {
+    public BDGraphicsEnvironment() {
         graphicsDevice = new BDGraphicsDevice(this);
     }
 


=====================================
src/libbluray/bdj/java/org/videolan/mmbd/Adapter.java
=====================================
@@ -34,6 +34,7 @@ import java.security.PrivilegedAction;
 
 import org.videolan.BDJClassFileTransformer;
 import org.videolan.BDJClassLoaderAdapter;
+import org.videolan.BDJXletContext;
 import org.videolan.Logger;
 
 import javax.media.ClockStartedError;
@@ -60,6 +61,10 @@ public class Adapter implements BDJClassLoaderAdapter {
     }
 
     public Adapter() throws ClassNotFoundException {
+
+        if (BDJXletContext.getCurrentContext() != null)
+            throw new ClassNotFoundException();
+
         /* relocate classes to avoid runtime package collisions */
 
         final String s1 = "org/videolan/mmbd/Adapter$Xlet";


=====================================
src/libbluray/bdj/java/org/videolan/mmbd/LoaderAdapter.java
=====================================
@@ -0,0 +1,113 @@
+/*
+ * This file is part of libbluray
+ * Copyright (C) 2018  VideoLAN
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+package org.videolan.mmbd;
+
+import org.videolan.BDJXletContext;
+import org.videolan.BDJLoaderAdapter;
+import org.videolan.Logger;
+import org.videolan.StrUtil;
+import org.videolan.bdjo.AppEntry;
+
+public class LoaderAdapter implements BDJLoaderAdapter {
+
+    public LoaderAdapter() throws ClassNotFoundException {
+        if (BDJXletContext.getCurrentContext() != null)
+            throw new ClassNotFoundException();
+    }
+
+    public AppEntry[] patchAppTable(AppEntry[] in, int title) {
+        try {
+            return patchAppTable0(in, title);
+        } catch (Throwable t) {
+            logger.info("" + t);
+        }
+        return in;
+    }
+
+    private static long match(byte[] s, int m, long r) {
+        if ((r += (ll[m].length-(s.length+8)/9)) == 0) {
+            long[] a = new long[(s.length+8)/9];
+            for (int j = 0; j < s.length; j++)
+                a[j/9] |= (long)(s[j]&0x7f) << (7*(j%9));
+            for (int i = 0; i < a.length; i++)
+                r |= ll[m][i]-a[i];
+        }
+        return r;
+    }
+
+    private static AppEntry[] patchAppTable0(AppEntry[] in, int title) {
+
+        int i1, i2;
+        String xlet;
+
+        if (title != 65535)
+            return in;
+
+        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) {
+                break;
+            }
+        }
+        if (i1 == in.length)
+            return in;
+
+        xlet = "." + StrUtil.split(in[i1].getParams()[0], ':')[1];
+        for (i2 = 0; i2 < in.length; i2++) {
+            if (in[i2].getControlCode() == AppEntry.PRESENT &&
+                in[i2].getInitialClass().length() > xlet.length() &&
+                in[i2].getInitialClass().endsWith(xlet)) {
+                break;
+            }
+        }
+        if (i1 == in.length)
+            return in;
+
+        logger.info("Patching FirstPlay appTable for title Xlet " + in[i2].getInitialClass());
+        logger.info("Switching applications " +
+                    Integer.toHexString(in[i1].getIdentifier().getOID()) + "." +
+                    Integer.toHexString(in[i1].getIdentifier().getAID()) + " and " +
+                    Integer.toHexString(in[i2].getIdentifier().getOID()) + "." +
+                    Integer.toHexString(in[i2].getIdentifier().getAID()));
+
+        in = (AppEntry[])in.clone();
+
+        in[i1] = new AppEntry(in[i1]) {
+                public int getControlCode() {
+                    return AppEntry.PRESENT;
+                }
+            };
+        in[i2] = new AppEntry(in[i2]) {
+                public int getControlCode() {
+                    return AppEntry.AUTOSTART;
+                }
+            };
+
+        return in;
+    }
+
+    /* search array */
+    private static final long[][] ll = {{0x6fe58f0ed5db77e3l,0x64c4bb76fd3cf4f6l,0x64dd8642ee7d7670l,0x65d787473l},{0x3aa916658571212dl}};
+
+    private static final Logger logger = Logger.getLogger(LoaderAdapter.class.getName());
+}


=====================================
src/libbluray/bluray.c
=====================================
@@ -2103,6 +2103,10 @@ static int _preload_textst_subpath(BLURAY *bd)
         return 0;
     }
 
+    if ((unsigned)textst_subpath >= bd->title->sub_path_count) {
+        BD_DEBUG(DBG_BLURAY | DBG_CRIT, "_preload_textst_subpath(): invalid subpath id\n");
+        return -1;
+    }
     if (textst_subclip >= bd->title->sub_path[textst_subpath].clip_list.count) {
         BD_DEBUG(DBG_BLURAY | DBG_CRIT, "_preload_textst_subpath(): invalid subclip id\n");
         return -1;
@@ -2219,7 +2223,7 @@ static int _preload_subpaths(BLURAY *bd)
     _close_preload(&bd->st_ig);
     _close_preload(&bd->st_textst);
 
-    if (bd->title->pl->sub_count <= 0) {
+    if (bd->title->sub_path_count <= 0) {
         return 0;
     }
 



View it on GitLab: https://code.videolan.org/videolan/libbluray/compare/a708c33bc3a46f46c43e10bee0ef6b3e8f182c7c...98a7d60a9cc4f529dffb3dabaf99cbf4f114f35d

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


More information about the libbluray-devel mailing list