-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
TarWriter writes badly formatted size field for a zero sized regular file #95354
Comments
This breaks unpacking by tar-rs alexcrichton/tar-rs#347 |
Tagging subscribers to this area: @dotnet/area-system-io-compression Issue DetailsDescriptionTarWriter writes badly formatted size field for a zero sized regular file Reproduction Stepsusing System;
using System.IO;
using System.Linq;
using System.Formats.Tar;
MemoryStream emptyData = new(0);
MemoryStream output = new();
TarWriter archive = new(output, TarEntryFormat.Pax);
PaxTarEntry te = new(TarEntryType.RegularFile, "zero_size")
{DataStream = emptyData};
archive.WriteEntry(te);
// get the size[12] field, after two unrelated blocks[512] and name[100], mode[8], uid[8], gid[8]
var offset = 2*512+100+3*8;
var sizeBuffer=output.GetBuffer()[offset..(offset+12)];
// it's "00000000000\0"
byte[] expected = new byte[] {0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0};
Console.WriteLine($"Proper size field: {sizeBuffer.SequenceEqual(expected)}"); Expected behaviorget all "0" in field (0x32) followed by "\0" Actual behaviorget binary zero Regression?No Known WorkaroundsNone ConfigurationAffected: (any with TarWriter)
Other informationNo response
|
Tagging subscribers to this area: @dotnet/area-system-formats-tar Issue DetailsDescriptionTarWriter writes badly formatted size field for a zero sized regular file Reproduction Stepsusing System;
using System.IO;
using System.Linq;
using System.Formats.Tar;
MemoryStream emptyData = new(0);
MemoryStream output = new();
TarWriter archive = new(output, TarEntryFormat.Pax);
PaxTarEntry te = new(TarEntryType.RegularFile, "zero_size")
{DataStream = emptyData};
archive.WriteEntry(te);
// get the size[12] field, after two unrelated blocks[512] and name[100], mode[8], uid[8], gid[8]
var offset = 2*512+100+3*8;
var sizeBuffer=output.GetBuffer()[offset..(offset+12)];
// it's "00000000000\0"
byte[] expected = new byte[] {0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0};
Console.WriteLine($"Proper size field: {sizeBuffer.SequenceEqual(expected)}"); Expected behaviorget all "0" in field (0x32) followed by "\0" Actual behaviorget binary zero Regression?No Known WorkaroundsNone ConfigurationAffected: (any with TarWriter)
Other informationNo response
|
Thanks for the report. Any interest in offering a PR? |
Ok, I'll try to fix this |
@danmoseley is there a website that displays current tests status? |
It seems the |
It is unusual that any tests fail in main. It really would only happen if they were outer loop as those aren't validated on every PR. |
Thanks for looking at it. It will need to include a test. (This can either be a unit test or a real file test, but the latter need to get committed to a test file repo before a test here can consume them) |
@sobczyk did you have a PR for this? Our window for 9.0 is closing soon, but we still have time to look at a PR if available in the next week or so. |
@ericstj the change is basically a one liner, the problem is that the unit tests are a bit messy |
This was fixed and ported to 9.0 - thank you @sobczyk and @carlossanlop |
Description
TarWriter writes badly formatted size field for a zero sized regular file
Reproduction Steps
Expected behavior
get all "0" in field (0x32) followed by "\0"
Actual behavior
get binary zero
Regression?
No
Known Workarounds
None
Configuration
Affected: (any with TarWriter)
Other information
No response
The text was updated successfully, but these errors were encountered: