You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create archive from /some/directory using SharpZipLib: recursive, set RootPath to /some/directory
Extact this archive using SharpZipLib
Expected behavior
Archive should be extracted
Actual behavior
InvalidNameException(Parent traversal in paths is not allowed)
Version of SharpZipLib
1.3.3
Obtained from (only keep the relevant lines)
Package installed using NuGet
Example
usingSystem.Text;usingICSharpCode.SharpZipLib.GZip;usingICSharpCode.SharpZipLib.Tar;vardirectory=$"/tmp/{Guid.NewGuid()}";Directory.CreateDirectory(directory);File.WriteAllText($"{directory}/1.txt","1");vararchiveFilePath=$"/tmp/{Guid.NewGuid()}.tar.gz";using(vararchiveStream=newGZipOutputStream(File.Create(archiveFilePath))){using(TarArchivetarArchive=TarArchive.CreateOutputTarArchive(archiveStream,Encoding.UTF8)){tarArchive.RootPath=directory;// this is workaround for another issue: tarArchive.RootPath is ignored otherwisewhile(tarArchive.RootPath.StartsWith("/",StringComparison.Ordinal)){tarArchive.RootPath=tarArchive.RootPath.Substring(1);}varentry=TarEntry.CreateEntryFromFile(directory);// ExtractContents fails without this line of code below: Parent traversal in paths is not allowed//entry.Name += "./";tarArchive.WriteEntry(entry,true);}}using(vararchiveStream=File.OpenRead(archiveFilePath)){using(vargzipStream=newGZipInputStream(archiveStream)){using(vartarArchive=TarArchive.CreateInputTarArchive(gzipStream,Encoding.UTF8)){tarArchive.ExtractContents($"/tmp/{Guid.NewGuid()}");}}}Console.WriteLine("Done");
The text was updated successfully, but these errors were encountered:
Steps to reproduce
Expected behavior
Archive should be extracted
Actual behavior
InvalidNameException(Parent traversal in paths is not allowed)
Version of SharpZipLib
1.3.3
Obtained from (only keep the relevant lines)
Example
The text was updated successfully, but these errors were encountered: