diff --git a/src/main/java/utilities/UnZip.java b/src/main/java/utilities/UnZip.java index fffa481..2014a9f 100644 --- a/src/main/java/utilities/UnZip.java +++ b/src/main/java/utilities/UnZip.java @@ -19,7 +19,10 @@ public static void unZip(String zippedFile, String outputFolder) { ze = zis.getNextEntry(); while (ze != null) { String fileName = ze.getName(); - File newFile = new File(outputFolder + File.separator + fileName); + File newFile = new File(outputFolder, fileName); + if (!newFile.toPath().normalize().startsWith(outputFolder)) { + throw new RuntimeException("Bad zip entry"); + } System.out.println("file unzip : " + newFile.getAbsoluteFile()); //create all non exists folders //else you will hit FileNotFoundException for compressed folder