From caaac4cbd93df9d825316ef03c8b3fd7d50edbeb Mon Sep 17 00:00:00 2001 From: Sergii Pylypenko Date: Sat, 11 Dec 2021 01:43:21 +0200 Subject: [PATCH] SDL: shut up Google Play security warning --- project/java/MainActivity.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/project/java/MainActivity.java b/project/java/MainActivity.java index f1fa1eda9..15716ba82 100644 --- a/project/java/MainActivity.java +++ b/project/java/MainActivity.java @@ -1274,6 +1274,11 @@ public class MainActivity extends Activity if( entry.isDirectory() ) { File outDir = new File( libDir.getAbsolutePath() + "/" + entry.getName() ); + if( !outDir.getCanonicalPath().startsWith(libDir.getAbsolutePath() + "/") ) + { + Log.i("SDL", "Security exception: " + outDir.getCanonicalPath()); + return; + } if( !(outDir.exists() && outDir.isDirectory()) ) outDir.mkdirs(); continue; @@ -1284,6 +1289,11 @@ public class MainActivity extends Activity try { File outDir = new File( path.substring(0, path.lastIndexOf("/") )); + if( !outDir.getCanonicalPath().startsWith(libDir.getAbsolutePath() + "/") ) + { + Log.i("SDL", "Security exception: " + outDir.getCanonicalPath()); + return; + } if( !(outDir.exists() && outDir.isDirectory()) ) outDir.mkdirs(); } @@ -1305,6 +1315,11 @@ public class MainActivity extends Activity } catch( Exception eeeeee ) { } Log.i("SDL", "Saving to file '" + path + "'"); + if( !(new File(path).getCanonicalPath().startsWith(libDir.getAbsolutePath() + "/")) ) + { + Log.i("SDL", "Security exception: " + path); + return; + } out = new FileOutputStream( path ); int len = zip.read(buf);