Skip to content

Tar: Detect magic numbers in archives compressed with popular algorithms #89056

@carlossanlop

Description

@carlossanlop

As suggested here: #74316 (comment)

Ideally, when reading a tar.xyz compressed file using TarFile or TarArchive APIs, we should detect the magic numbers at the beginning of the archive, determine the archive is compressed, and throw a friendlier error message. We currently throw Unable to parse number in ThrowInvalidNumber(). And we could offer two variations of the same exception:

  • If we support the compression algorithm, suggest wrapping the archive with a stream class for that algorithm (DeflateStream, GZipStream, ZLibStream).
  • If we don't support the compression algorithm, but it has magic numbers, detect them, mention the algorithm is currently unsupported.

Note: We have proposal #70517 to track the request to be able to open tar.gz files, since we support gzip. TarFile and TarArchive support the tar format only, no compression.

Metadata

Metadata

Assignees

Labels

area-System.Formats.Tarin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions