SDL: shut up Google Play security warning

This commit is contained in:
Sergii Pylypenko
2021-12-11 01:43:21 +02:00
parent b63e1c0ed8
commit caaac4cbd9

View File

@@ -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);