Skip to content
This repository has been archived by the owner on Oct 5, 2022. It is now read-only.

Commit

Permalink
This will not extract file to any random directory
Browse files Browse the repository at this point in the history
  • Loading branch information
rupalibehera committed Jun 5, 2018
1 parent a7f7364 commit c7d4db1
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ public static void unzip(InputStream in, File toDir) throws IOException {
if (!entry.isDirectory()) {
String entryName = entry.getName();
File toFile = new File(toDir, entryName);
String fileDestinationFullPath = toFile.getPath();
try{
if (!fileDestinationFullPath.startsWith(toDir.getPath())); throw new IOException("Extracting results to different directory");

}catch (IOException e){
System.out.println(e);
System.exit(1);
}

toFile.getParentFile().mkdirs();
OutputStream os = new FileOutputStream(toFile);
try {
Expand Down

0 comments on commit c7d4db1

Please sign in to comment.