Description
Description
The current TarReader treats any extended headers which contain an equals sign as invalid. While I am not sure about the exact spec, it is in conflict with the MSWINDOWS.rawsd
extension which is used to define the Windows Security Descriptors for files. They are supposed to be encoded as base64 which can have =
signs as padding characters.
Reproduction Steps
using System.Formats.Tar;
using var data = new MemoryStream();
using (var writer = new TarWriter(data, TarEntryFormat.Pax, leaveOpen: true))
{
writer.WriteEntry(new PaxTarEntry(TarEntryType.RegularFile, "file.txt", new Dictionary<string, string>
{
["MSWINDOWS.rawsd"] = "AQAAgBQAAAAkAAAAAAAAAAAAAAABAgAAAAAABSAAAAAhAgAAAQIAAAAAAAUgAAAAIQIAAA=="
})
{
DataStream = new MemoryStream("Hello Pax"u8.ToArray())
});
}
data.Position = 0;
using (var reader = new TarReader(data, leaveOpen: true))
{
var entry = (PaxTarEntry)reader.GetNextEntry();
if (!entry.ExtendedAttributes.TryGetValue("MSWINDOWS.rawsd", out var descriptor))
{
descriptor = "missing!";
}
Console.WriteLine("Security Descriptor: {0}", descriptor);
}
Expected behavior
Output should show Security Descriptor: AQAAgBQAAAAkAAAAAAAAAAAAAAABAgAAAAAABSAAAAAhAgAAAQIAAAAAAAUgAAAAIQIAAA==
Actual behavior
Output shows Security Descriptor: missing!
Regression?
No, was like this since the beginning.
Known Workarounds
None known.
Configuration
.net Version: 7.0.102
Edition Windows 11 Enterprise
Version 22H2
Installed on 25/01/2023
OS build 22621.1105
Experience Windows Feature Experience Pack 1000.22638.1000.0
Architecture: x64
Other information
It currently seems by design to treat equals sign values as invalid even though it shouldn't be a problem to support it. From the remaining parsing code it seems to be expected that properties are separated by newlines and key-value by the first equals sign.
Related code:
I was extending https://github.com/dotnet/sdk-container-builds with features to support Windows Containers better and ran into this problem while creating unit tests to verify that the extended attributes are written.