Skip to content

Commit 5c3b293

Browse files
committed
fix: specialized tar extract traversal
1 parent a0e96de commit 5c3b293

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/ICSharpCode.SharpZipLib/Tar/TarArchive.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,8 +658,9 @@ private void ExtractEntry(string destDir, TarEntry entry, bool allowParentTraver
658658
name = name.Replace('/', Path.DirectorySeparatorChar);
659659

660660
string destFile = Path.Combine(destDir, name);
661+
var destFileDir = Path.GetDirectoryName(Path.GetFullPath(destFile)) ?? "";
661662

662-
if (!allowParentTraversal && !Path.GetFullPath(destFile).StartsWith(destDir, StringComparison.InvariantCultureIgnoreCase))
663+
if (!allowParentTraversal && !destFileDir.StartsWith(destDir, StringComparison.InvariantCultureIgnoreCase))
663664
{
664665
throw new InvalidNameException("Parent traversal in paths is not allowed");
665666
}

0 commit comments

Comments
 (0)