Skip to content

Commit

Permalink
fix(common-utils): Do not extract TAR directory entries as files
Browse files Browse the repository at this point in the history
This works around [1]. Still keep the `isFile` check to be on the safe
side and e.g. skip links.

Resolves #8098.

[1]: https://issues.apache.org/jira/browse/COMPRESS-657

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Jan 11, 2024
1 parent 3d911f0 commit d0301b4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion utils/common/src/main/kotlin/ArchiveUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,9 @@ fun InputStream.unpackZip(targetDirectory: File) =
fun InputStream.unpackTar(targetDirectory: File, filter: (ArchiveEntry) -> Boolean = { true }) =
TarArchiveInputStream(this).unpack(
targetDirectory,
{ entry -> !(entry as TarArchiveEntry).isFile || File(entry.name).isAbsolute || !filter(entry) },
{ entry ->
(entry as TarArchiveEntry).isDirectory || !entry.isFile || File(entry.name).isAbsolute || !filter(entry)
},
{ entry -> (entry as TarArchiveEntry).mode }
)

Expand Down

0 comments on commit d0301b4

Please sign in to comment.