-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
When constructing a Pax GEA entry, we internally call the base constructor by passing the formattable string GlobalHeadFormatPrefix:
Lines 28 to 29 in 434e7f6
| public PaxGlobalExtendedAttributesTarEntry(IEnumerable<KeyValuePair<string, string>> globalExtendedAttributes) | |
| : base(TarEntryType.GlobalExtendedAttributes, TarHeader.GlobalHeadFormatPrefix, TarEntryFormat.Pax, isGea: true) |
But it is not getting filled out anywhere yet. At that point, the name value would be mostly useless. If the user consults the Name property to see the value, it will be malformed/incomplete.
The place where we properly fill out the name field for this entry is when we the entry to the archive:
runtime/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Write.cs
Lines 902 to 917 in 434e7f6
| private static string GenerateGlobalExtendedAttributeName(int globalExtendedAttributesEntryNumber) | |
| { | |
| Debug.Assert(globalExtendedAttributesEntryNumber >= 1); | |
| string tmpDir = Path.GetTempPath(); | |
| if (Path.EndsInDirectorySeparator(tmpDir)) | |
| { | |
| tmpDir = Path.TrimEndingDirectorySeparator(tmpDir); | |
| } | |
| int processId = Environment.ProcessId; | |
| string result = string.Format(GlobalHeadFormatPrefix, tmpDir, processId); | |
| string suffix = $".{globalExtendedAttributesEntryNumber}"; // GEA sequence number | |
| if (result.Length + suffix.Length >= FieldLengths.Name) | |
| { | |
| result = string.Format(GlobalHeadFormatPrefix, "/tmp", processId); |
At that point, we should know the counter position number of the current GEA entry, as well as the tmp folder path, both which get formatted into that string.
So we should just set the name to empty in that base constructor name.
Thanks @stephentoub for finding this.