[libbluray-devel] JSM: fix handling of relative parths

hpi1 git at videolan.org
Tue Mar 31 11:44:58 CEST 2015


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Tue Mar 31 12:36:05 2015 +0300| [8ed41e3afcacd73289c64259d13af18c0086d501] | committer: hpi1

JSM: fix handling of relative parths

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=8ed41e3afcacd73289c64259d13af18c0086d501
---

 src/libbluray/bdj/java/java/io/BDFileSystem.java           |    2 +-
 .../bdj/java/org/videolan/BDJSecurityManager.java          |   12 +++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/libbluray/bdj/java/java/io/BDFileSystem.java b/src/libbluray/bdj/java/java/io/BDFileSystem.java
index 276d38c..508014e 100644
--- a/src/libbluray/bdj/java/java/io/BDFileSystem.java
+++ b/src/libbluray/bdj/java/java/io/BDFileSystem.java
@@ -126,7 +126,7 @@ public abstract class BDFileSystem extends FileSystem {
         return fs.prefixLength(pathname);
     }
 
-    private boolean isAbsolutePath(String path) {
+    public static boolean isAbsolutePath(String path) {
         return path.startsWith("/") || path.indexOf(":\\") == 1 ||
             path.startsWith("\\");
     }
diff --git a/src/libbluray/bdj/java/org/videolan/BDJSecurityManager.java b/src/libbluray/bdj/java/org/videolan/BDJSecurityManager.java
index 9e60282..8a692d0 100644
--- a/src/libbluray/bdj/java/org/videolan/BDJSecurityManager.java
+++ b/src/libbluray/bdj/java/org/videolan/BDJSecurityManager.java
@@ -241,8 +241,18 @@ final class BDJSecurityManager extends SecurityManager {
         throw new SecurityException("write access denied");
     }
 
-    private String getCanonPath(final String path)
+    private String getCanonPath(String origPath)
     {
+        if (!java.io.BDFileSystem.isAbsolutePath(origPath)) {
+            String home = BDJXletContext.getCurrentXletHome();
+            if (home == null) {
+                logger.error("Relative path " + origPath + " outside Xlet context\n" + Logger.dumpStack());
+                return origPath;
+            }
+            origPath = home + origPath;
+        }
+
+        final String path = origPath;
         String cpath = (String)AccessController.doPrivileged(new PrivilegedAction() {
             public Object run() {
                 try {



More information about the libbluray-devel mailing list