Description
Steps to reproduce
- Create an output tar archive.
- Set the root path to something in the same directory as the exe (so if the exe was
C:\tools\thingWithTar.exe
, set the root toC:\tools\dirToSetAsRoot
) - Attempt to add a file with the path
C:\tools\dirToSetAsRoot\fileToSend.txt
Because the file name of the file to add has the current directory as the substring, TarEntry.CreateEntryFromFile
, when it calls TarEntry.GetTarFileHeader
, will set the name to
dirToSetAsRoot\fileToSend.txt
(this occurs on line 384 of TarEntry.cs)
Because the root path is no longer part of the name, it is not compared, and the entry added to the tar archive remains darToSetAsRoot\fileToSend.txt
.
However, if the file was not a child of the current directory:
- Set root to
C:\notCurDir\dirToSetAsRoot
- Attempt to add file
C:\notCurDir\dirToSetAsRoot\fileToSend.txt
Then, TarEntry.CreateEntryFromFile
names the entry: C:\notCurDir\dirToSetAsRoot\fileToSend.txt
Then, when written to the tar archive, the root is compared with the entry from string, which leads to the file being written as:
fileToSend.txt
Expected behavior
Behavior of adding files, relative to root path, should be the same regardless if the file being added is a child of the current working directory.
Actual behavior
The entry name differs if the file to add is a child of the current directory.
Version of SharpZipLib
1.1.0
Obtained from (only keep the relevant lines)
- Package installed using NuGet