Skip to content

Commit

Permalink
add filename check for unTar
Browse files Browse the repository at this point in the history
  • Loading branch information
hangc0276 committed Mar 4, 2024
1 parent 7576f22 commit 4ef4e29
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ private static void unTar(final File inputFile, final File outputDir) throws Exc
TarArchiveEntry entry;
while ((entry = (TarArchiveEntry) debInputStream.getNextEntry()) != null) {
final File outputFile = new File(outputDir, entry.getName());
if (!outputFile.toPath().normalize().startsWith(outputDir.toPath())) {
throw new Exception("Bad zip entry");
}

if (!outputFile.getParentFile().exists()) {
outputFile.getParentFile().mkdirs();
}
Expand Down

0 comments on commit 4ef4e29

Please sign in to comment.