[Android] Fix Unsanitized file entry

Geoffrey Métais git at videolan.org
Thu Jan 24 10:26:46 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jan 24 09:27:13 2019 +0100| [338297af8e64b87d4ec7185ddc2b80a0fe640f86] | committer: Geoffrey Métais

Fix Unsanitized file entry

> https://code.videolan.org/videolan/vlc-android/commit/338297af8e64b87d4ec7185ddc2b80a0fe640f86
---

 vlc-android/src/org/videolan/vlc/util/FileUtils.java | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/util/FileUtils.java b/vlc-android/src/org/videolan/vlc/util/FileUtils.java
index 5697282d9..f4d808efc 100644
--- a/vlc-android/src/org/videolan/vlc/util/FileUtils.java
+++ b/vlc-android/src/org/videolan/vlc/util/FileUtils.java
@@ -470,28 +470,26 @@ public class FileUtils {
 
     public static ArrayList<String> unpackZip(String path, String unzipDirectory)
     {
-        InputStream is;
-        ZipInputStream zis;
-        ArrayList<String> unzippedFiles = new ArrayList();
+        final InputStream is;
+        final ZipInputStream zis;
+        final ArrayList<String> unzippedFiles = new ArrayList<>();
         try
         {
             is = new FileInputStream(path);
             zis = new ZipInputStream(new BufferedInputStream(is));
             ZipEntry ze;
 
-            while((ze = zis.getNextEntry()) != null)
-            {
+            while((ze = zis.getNextEntry()) != null) {
                 ByteArrayOutputStream baos = new ByteArrayOutputStream();
                 byte[] buffer = new byte[1024];
                 int count;
 
-                String filename = ze.getName();
+                final String filename = ze.getName().replace('/', ' ');
                 File fileToUnzip = new File(unzipDirectory, filename);
                 FileOutputStream fout = new FileOutputStream(fileToUnzip);
 
                 // reading and writing
-                while((count = zis.read(buffer)) != -1)
-                {
+                while((count = zis.read(buffer)) != -1) {
                     baos.write(buffer, 0, count);
                     byte[] bytes = baos.toByteArray();
                     fout.write(bytes);
@@ -505,8 +503,7 @@ public class FileUtils {
 
             zis.close();
         }
-        catch(IOException e)
-        {
+        catch(IOException e) {
             e.printStackTrace();
         }
 



More information about the Android mailing list