icsharpcode / SharpZipLib

#ziplib is a Zip, GZip, Tar and BZip2 library written entirely in C# for the .NET platform.
http://icsharpcode.github.io/SharpZipLib/
MIT License
3.7k stars 976 forks source link

Symlink creation not possible with `TarArchive.WriteEntry()`. #850

Open nptr opened 10 months ago

nptr commented 10 months ago

Describe the bug

Creating a symlink with TarArchive.WriteEntry() fails with an ArgumentNullException which i think is unfounded. Reason seems to be, that WriteEntry() expected file data where there should't be any. Creating a directory (where there also isn't data) succeeds because there is a separate code path to handle this case. I would expect that LF_SYMLINK is also exempted.

Reproduction Code

https://dotnetfiddle.net/faKmUo

Steps to reproduce

  1. Open the link to the reproduction at dotnetfiddle.
  2. Run the code.
  3. Observe that SymlinkWithArchiveClass() failed.

Expected behavior

I would expect that SymlinkWithArchiveClass() succeeds, just like the lower level example SymlinkWithStreamClass(), that directly utilized TarOutputStream, does.

Operating System

Windows, macOS, Linux

Framework Version

.NET 7, .NET 6, .NET Framework 4.x

Tags

Tar

Additional context

No response

piksel commented 10 months ago

This is more of a feature request, I think. TarArchive does more of the heavy lifting, but at a cost of less flexibility. It shouldn't be much of a problem to skip reading the source if the size is set to 0, though...