Merge pull request #904 from rneatherway/zipslip-fix

Java: Add a flow step for `Path::toFile` in ZipSlip
This commit is contained in:
Anders Schack-Mulligen
2019-02-11 13:08:38 +01:00
committed by GitHub
3 changed files with 12 additions and 0 deletions

View File

@@ -51,4 +51,13 @@ public class ZipTest {
throw new Exception();
FileOutputStream os = new FileOutputStream(file); // OK
}
public void m6(ZipEntry entry, Path dir) {
String canonicalDest = dir.toFile().getCanonicalPath();
Path target = dir.resolve(entry.getName());
String canonicalTarget = target.toFile().getCanonicalPath();
if (!canonicalTarget.startsWith(canonicalDest + File.separator))
throw new Exception();
OutputStream os = Files.newOutputStream(target); // OK
}
}