Skip to content

Tar entries should be able to handle paths that begin with "./", including the root path itself #70516

Closed
@carlossanlop

Description

@carlossanlop

Description

Bug found while investigating this issue: #70509

TarReader.GetNextEntry is unable to retrieve entries that have the path set to ./.

Reproduction Steps

Download https://dotnetcli.azureedge.net/dotnet/Runtime/6.0.5-servicing.22213.9/dotnet-runtime-6.0.5-osx-x64.tar.gz

string targetPath = "D:/some/destination";
using FileStream compressedStream = File.OpenRead(@"D:/path/to/dotnet-runtime-6.0.5-osx-x64.tar.gz");
using GZipStream decompressor = new(compressedStream, CompressionMode.Decompress);
TarFile.ExtractToDirectory(source: decompressor, destinationDirectoryName: targetPath, overwriteFiles: true);

Expected behavior

The archive is extracted.

Actual behavior

    System.IO.IOException : Extracting the Tar entry './' would have resulted in a file outside the specified destination directory: 'C:\Users\carlos\AppData\Local\Temp\zm5gtquh.qu5\'

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions