Skip to content

Tar: ustar entries with long name unable to roundtrip #75360

Closed

Description

@jozkee

When you use new UstarTarEntry(TarEntryType entryType, string entryName) there's no exception about the entryName length, so I would expect that the format could handle any name but when I try to write a name larger than 100, the chars past 100 are written to the prefix.
When you read back the entry, we concat prefix + '/' + name, which makes the name different to what you wrote.

MemoryStream ms = new();
using (TarWriter writer = new(ms, true))
{
    TarEntry entry = new UstarTarEntry(TarEntryType.RegularFile, new string('a', 100) + new string('b', 155));
    Console.WriteLine("Entry name on write: " + entry.Name); // prints aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
    writer.WriteEntry(entry);
}

ms.Position =  0;
using (TarReader reader = new TarReader(ms))
{
    TarEntry entry = reader.GetNextEntry();
    Console.WriteLine("Entry name on reading: " + entry.Name); // prints bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
}

We need to align name and prefix behavior on read and write on ustar entries.
Aditionally, one way to set expectations about name lengths is to raise exceptions for names that would be truncated. For example, for V7 we can throw for names > 100 and for ustar we can throw for names > 255.

cc @carlossanlop

Activity

  1. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Sep 9, 2022
  2. removed
    untriagedNew issue has not been triaged by the area owner
    on Sep 9, 2022
  3. self-assigned this
    on Sep 9, 2022
  4. added this to the 8.0.0 milestone on Sep 9, 2022
  5. jozkee commented on Sep 9, 2022

    @jozkee
    MemberAuthor

    Moving to 8.0 as ustar is not a very popular format and the workaround is to use Pax or Gnu format instead.

  6. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Sep 26, 2022
  7. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Sep 28, 2022
  8. kasperk81 commented on Oct 3, 2022

    @kasperk81
    Contributor

    fix is being backported #76322, so milestone 7?

  9. jozkee commented on Oct 3, 2022

    @jozkee
    MemberAuthor

    @kasperk81 still needs approval to be merged into 7.0

  10. modified the milestones: 8.0.0, 7.0.0 on Oct 6, 2022
  11. ghost locked as resolved and limited conversation to collaborators on Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions