-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Description
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.
carlossanlop