Merge pull request #5613 from trungPa/JENKINS-66094

[JENKINS-66094]Use Path.startsWith() for subdirectory check when unzipping
This commit is contained in:
Raihaan Shouhell authored and GitHub committed 2021-07-25 22:02:52 +08:00
commit b8127af111
4 files changed
+60 -1

No files matched your search

+1 -1
View File
@@ -696,7 +696,7 @@ public final class FilePath implements SerializableOnlyOverRemoting {
while (entries.hasMoreElements()) {
ZipEntry e = entries.nextElement();
File f = new File(dir, e.getName());
if (!f.getCanonicalPath().startsWith(dir.getCanonicalPath())) {
if (!f.getCanonicalFile().toPath().startsWith(dir.getCanonicalPath())) {
throw new IOException(
"Zip " + zipFile.getPath() + " contains illegal file name that breaks out of the target directory: " + e.getName());
}