Skip to content

PAX GEA constructor setting the name value to the unformatted string #77555

@carlossanlop

Description

@carlossanlop

When constructing a Pax GEA entry, we internally call the base constructor by passing the formattable string GlobalHeadFormatPrefix:

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:

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions