Skip to content

Commit

Permalink
[SECURITY] Fix Zip Slip Vulnerability (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg authored Aug 9, 2022
2 parents fe20831 + 6434749 commit 25f04f6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/com/diffplug/gradle/ZipMisc.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ public static void unzip(File input, File destinationDir) throws IOException {
ZipEntry entry;
while ((entry = zipInput.getNextEntry()) != null) {
File dest = new File(destinationDir, entry.getName());
if (!dest.toPath().normalize().startsWith(destinationDir.toPath().normalize())) {
throw new RuntimeException("Bad zip entry");
}
if (entry.isDirectory()) {
FileMisc.mkdirs(dest);
} else {
Expand Down

0 comments on commit 25f04f6

Please # to comment.