Skip to content

TarEntry does not support absolute paths #338

Open

Description

@iUnknwn

Currently, TarEntry.cs, in GetFileTarHeader, trims all leading forward slashes.

Trying to write /home/username/foo.txt as an entry would to write home/username/foo.txt

This prevents writing absolute paths to the archive, and also breaks the RootPath string, as the entry name will no longer have the root path as a sub string (if it was set to /home/username), so it will never match when the entry is added to the archive.

If we're trying to specifically avoid UNC path names, it might be easier to just test for a leading double back slash in the original path (instead of testing for leading slashes).

Expected behavior

RootPath should work as expected when adding absolute paths on POSIX.

Actual behavior

RootPath does not work as expected - file strings will never match RootPath because RootPath will still contain the leading '/', but the file entry will not.

Additionally, absolute file paths will be broken, regardless if root path is used.

Version of SharpZipLib

1.1.0

Obtained from (only keep the relevant lines)

  • Package installed using NuGet

Activity

  1. added a commit that references this issue on Apr 13, 2019
  2. added
    tar
    on Jun 18, 2019
  3. added a commit that references this issue on Oct 31, 2019
  4. piksel commented on Feb 1, 2020

    @piksel
    Member

    Couldn't you just set the RootPath to "home/username"?

  5. piksel commented on Nov 22, 2020

    @piksel
    Member

    This is probably a duplicate of #38 (how fitting). But that one only contains dead links and not a clear description. Closing it in favor of this one.

  6. reopened this on Nov 22, 2020
  7. changed the title [-]Tar does not handle POSIX absolute paths correctly (trims leading '/'), breaks RootPath[/-] [+]TarEntry does not support absolute paths[/+] on Nov 22, 2020
  8. added
    enhancement
    on Nov 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementtar

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions