- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
std.tar: support pax headers and gnu_long{name,link} #15382
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9a97261
std.tar: support pax headers and gnulong_{name,link}
travisstaloch df0829d
std.tar: fix fuzzing crashes part 1
travisstaloch 52ef4ce
std.tar: fix fuzzing crashes part 2
travisstaloch 33d1f33
std.tar: fix fuzzing crashes part 3
travisstaloch dd21d6a
std.tar: chore - update to latest zig
travisstaloch 0289688
std.tar: chore - update to zig 0.11.0-dev.3910+689f3163a
travisstaloch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,4 +46,5 @@ test { | |
_ = xz; | ||
_ = zlib; | ||
_ = zstd; | ||
_ = @import("compress/tar.zig"); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
test { | ||
_ = @import("tar/reader_test.zig"); | ||
_ = @import("tar/test_decompress.zig"); | ||
} | ||
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const std = @import("std"); | ||
|
||
/// testing helper for decompressing a .gz file. returns an io.fixedBufferStream | ||
/// with the decompressed data. caller owns the returned FixedBufferStream.buffer | ||
pub fn decompressGz( | ||
comptime file_name: []const u8, | ||
alloc: std.mem.Allocator, | ||
) !std.io.FixedBufferStream([]u8) { | ||
var fbs = std.io.fixedBufferStream(@embedFile(file_name)); | ||
var decompressor = try std.compress.gzip.decompress(alloc, fbs.reader()); | ||
defer decompressor.deinit(); | ||
const decompressed = try decompressor.reader().readAllAlloc(alloc, 1024 * 32); | ||
return std.io.fixedBufferStream(decompressed); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const std = @import("std"); | ||
const mem = std.mem; | ||
const tar = std.tar; | ||
const testing = std.testing; | ||
const talloc = testing.allocator; | ||
const builtin = @import("builtin"); | ||
const test_common = @import("test_common.zig"); | ||
|
||
test "std.tar decompress testdata" { | ||
// skip due to 'incorrect alignment', maybe the same as | ||
// https://github.com/ziglang/zig/issues/14036 | ||
if (builtin.os.tag == .windows and builtin.mode == .Debug) | ||
return error.SkipZigTest; | ||
|
||
const test_files = [_][]const u8{ | ||
"xattrs.tar", | ||
"gnu-long-nul.tar", | ||
"v7.tar", | ||
"pax-bad-hdr-file.tar", | ||
"pax-global-records.tar", | ||
"star.tar", | ||
"pax-multi-hdrs.tar", | ||
"gnu.tar", | ||
"gnu-utf8.tar", | ||
"trailing-slash.tar", | ||
"pax.tar", | ||
"nil-uid.tar", | ||
"ustar-file-devs.tar", | ||
"pax-pos-size-file.tar", | ||
"hardlink.tar", | ||
"pax-records.tar", | ||
"gnu-multi-hdrs.tar", | ||
"hardlink.tar", | ||
"dir-symlink.tar", | ||
}; | ||
|
||
inline for (test_files) |test_file| { | ||
var fbs = try test_common.decompressGz("testdata/" ++ test_file ++ ".gz", talloc); | ||
defer talloc.free(fbs.buffer); | ||
try testDecompressTarToTmp(&fbs, .{ .mode_mode = .ignore }); | ||
fbs.reset(); | ||
try testDecompressTarToTmp(&fbs, .{ .mode_mode = .executable_bit_only }); | ||
} | ||
} | ||
|
||
fn testDecompressTarToTmp(fbs: *std.io.FixedBufferStream([]u8), options: tar.Options) !void { | ||
var tmpdir = testing.tmpDir(.{}); | ||
defer tmpdir.cleanup(); | ||
try tar.pipeToFileSystem(talloc, tmpdir.dir, fbs.reader(), options); | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this file, this looks like a big kludge