Skip to content

Commit ef41213

Browse files
authored
Update Zip.java
1 parent 3744929 commit ef41213

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

java/src/org/openqa/selenium/io/Zip.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ public static void unzip(InputStream source, File outputDir) throws IOException
102102
while ((entry = zis.getNextEntry()) != null) {
103103
File file = new File(outputDir, entry.getName());
104104
if (entry.isDirectory()) {
105+
String canonicalOutputDirPath = outputDir.getCanonicalPath();
106+
String canonicalDirPath = file.getCanonicalPath();
107+
if (!canonicalDirPath.startsWith(canonicalOutputDirPath + File.separator)) {
108+
throw new IOException("Directory entry is outside of the target dir: " + entry.getName());
109+
}
105110
FileHandler.createDir(file);
106111
continue;
107112
}

0 commit comments

Comments
 (0)