-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tar: ustar entries with long name unable to roundtrip #75360
Comments
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsWhen you use 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.
|
Moving to 8.0 as ustar is not a very popular format and the workaround is to use Pax or Gnu format instead. |
fix is being backported #76322, so milestone 7? |
@kasperk81 still needs approval to be merged into 7.0 |
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.
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
The text was updated successfully, but these errors were encountered: