Skip to content

Commit

Permalink
fix security problem as the CI alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
wuchaojing committed Mar 3, 2023
1 parent a664be2 commit 38a0aad
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Paths;
import java.util.Enumeration;
Expand Down Expand Up @@ -204,6 +205,11 @@ private void unZipFile(final ZipFile zipFile, final ZipArchiveEntry entry,
final String targetDir)
throws Exception {
final File targetFile = new File(Paths.get(targetDir, entry.getName()).toString());
if (!targetFile.toPath().normalize().startsWith(targetDir)) {
throw new IOException(String.format("Bad entry: %s",
entry.getName()));
}

FileUtils.forceMkdir(targetFile.getParentFile());
try (final InputStream is = zipFile.getInputStream(entry);
final BufferedInputStream fis = new BufferedInputStream(is);
Expand Down

0 comments on commit 38a0aad

Please sign in to comment.