Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TarReader throws System.IO.InvalidDataException: 'Unable to parse number.' #122635

@TFTomSun

Description

@TFTomSun

Description

System.IO.InvalidDataException
HResult=0x80131501
Message=Unable to parse number.
Source=System.Formats.Tar
StackTrace:
at System.Formats.Tar.TarHelpers.ThrowInvalidNumber()
at System.Formats.Tar.TarHelpers.ParseOctal[T](ReadOnlySpan1 buffer) at System.Formats.Tar.TarHeader.TryReadCommonAttributes(ReadOnlySpan1 buffer, TarEntryFormat initialFormat)
at System.Formats.Tar.TarHeader.TryReadAttributes(TarEntryFormat initialFormat, ReadOnlySpan1 buffer, Stream archiveStream) at System.Formats.Tar.TarHeader.<TryGetNextHeaderAsync>d__49.MoveNext() at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable1.ConfiguredValueTaskAwaiter.GetResult()
at System.Formats.Tar.TarReader.d__15.MoveNext()
at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable1.ConfiguredValueTaskAwaiter.GetResult() at System.Formats.Tar.TarReader.<GetNextEntryInternalAsync>d__13.MoveNext() at System.Runtime.CompilerServices.ValueTaskAwaiter1.GetResult()
at ZipArchiveExtensions.d__0.MoveNext() in D:\git\collaboration\apis.core2\src\Siemens.Collaboration.Net.CoreExtensions\Zip_global\ZipArchiveExtensions.cs:line 36
at ZipArchiveExtensions.d__0.MoveNext() in D:\git\collaboration\apis.core2\src\Siemens.Collaboration.Net.CoreExtensions\Zip_global\ZipArchiveExtensions.cs:line 36

This exception was originally thrown at this call stack:
System.Formats.Tar.TarHelpers.ThrowInvalidNumber()
System.Formats.Tar.TarHelpers.ParseOctal(System.ReadOnlySpan)
System.Formats.Tar.TarHeader.TryReadCommonAttributes(System.ReadOnlySpan, System.Formats.Tar.TarEntryFormat)
System.Formats.Tar.TarHeader.TryReadAttributes(System.Formats.Tar.TarEntryFormat, System.ReadOnlySpan, System.IO.Stream)
System.Formats.Tar.TarHeader.TryGetNextHeaderAsync(System.IO.Stream, bool, System.Formats.Tar.TarEntryFormat, bool, System.Threading.CancellationToken)
System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable.ConfiguredValueTaskAwaiter.GetResult()
System.Formats.Tar.TarReader.TryGetNextEntryHeaderAsync(bool, System.Threading.CancellationToken)
System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable.ConfiguredValueTaskAwaiter.GetResult()
System.Formats.Tar.TarReader.GetNextEntryInternalAsync(bool, System.Threading.CancellationToken)
System.Runtime.CompilerServices.ValueTaskAwaiter.GetResult()
...
[Call Stack Truncated]

Reproduction Steps

I try to untar the following file with dotnet 10:
https://github.com/qdrant/qdrant/releases/download/v1.16.2/qdrant-x86_64-unknown-linux-gnu.tar.gz

public static async Task UntarAsync(this TarArchive tarArchive, DirectoryInfo outputDirectory, bool overwrite = false, CancellationToken cancellation = default)
{
    await using var tarStream = tarArchive.ReadStreamFactory();
    await using var tarReader = new System.Formats.Tar.TarReader(tarStream);
    System.Formats.Tar.TarEntry entry;
    while ((entry = await tarReader.GetNextEntryAsync()) != null)
    {
        if (entry.EntryType is System.Formats.Tar.TarEntryType.SymbolicLink or System.Formats.Tar.TarEntryType.HardLink or System.Formats.Tar.TarEntryType.GlobalExtendedAttributes)
        {
            continue;
        }

        await entry.ExtractToFileAsync(outputDirectory.Combine(entry.Name), overwrite, cancellation);
    }

}
Image

Expected behavior

The code runs succesful

Actual behavior

It fails with the exception mentioned above

Regression?

There was already a fix merged for dotnet 9. However it still seem to fail in dotnet 10. #93763

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions