New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Tar with large entry size #96209
Comments
Tagging subscribers to this area: @dotnet/area-system-formats-tar Issue DetailsDescriptionCurrently i cannot use Reproduction Stepsusing TarReader tar = new TarReader(tarStream, true);
List<TarEntry> entries = new List<TarEntry>();
while (true)
{
TarEntry? entry = await tar.GetNextEntryAsync();
if (entry == null)
{
break;
}
entries.Add(entry);
}
... Expected behaviorNot error Actual behaviorerror:
Regression?No response Known Workaroundsthis is currently my own tar parser implementation: public async Task<TarEntry[]> GetEntriesAsync(Stream tarStream, CancellationToken cancellationToken)
{
byte[] entryHeaderBuff = new byte[512];
List<TarEntry> entries = new List<TarEntry>();
while (true)
{
cancellationToken.ThrowIfCancellationRequested();
entryHeaderBuff[0] = 0; // Reset flag.
int read = await tarStream.ReadAsync(
entryHeaderBuff,
cancellationToken);
if (read < entryHeaderBuff.Length ||
entryHeaderBuff[0] == 0)
{
// No more entries.
break;
}
string fileName = Encoding.ASCII.GetString(entryHeaderBuff, 0, 100).Trim('\0');
long fileSize;
if (entryHeaderBuff[124] == 0x80)
{
byte[] sizeBuff = new byte[8];
entryHeaderBuff
.AsSpan()
.Slice(124 + 4, 8)
.CopyTo(sizeBuff);
Array.Reverse(sizeBuff);
fileSize = BitConverter.ToInt64(sizeBuff);
}
else
{
string sizeStr = Encoding.UTF8.GetString(entryHeaderBuff, 124, 12).Trim('\0');
fileSize = Convert.ToInt64(sizeStr, 8);
}
entries.Add(new TarEntry(fileName, fileSize));
// Next.
tarStream.Seek((fileSize + 511) / 512 * 512, SeekOrigin.Current);
}
return entries.ToArray();
} ConfigurationNo response Other informationNo response
|
closing in favor of #93763 |
Description
Currently i cannot use
TarReader.GetNextEntryAsync
whenever it sees a tar entry file with more than 8GB of size (my case is 9GB). In the entry header itself, instead of writing size of the file in octal, the size header is constructed like this:[0x80, 0, 0, 0, <size in bytes big endian>]
Reproduction Steps
Expected behavior
Not error
Actual behavior
error:
Regression?
No response
Known Workarounds
this is currently my own tar parser implementation:
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: