mirror of
https://github.com/ziglang/zig.git
synced 2026-02-20 16:24:51 +00:00
fix crash in tar found by fuzzing
Running fuzzing tar test with [zig std lib fuzzing](https://github.com/squeek502/zig-std-lib-fuzzing) reached and assert in tar implementation. Assert (in std lib) should not be reachable by external input, so I'm fixing this to return error.
This commit is contained in:
parent
8802ec583b
commit
30f15e3afe
@ -300,7 +300,7 @@ fn Iterator(comptime ReaderType: type) type {
|
||||
}
|
||||
|
||||
inline fn readString(self: *Self, size: usize, buffer: []u8) ![]const u8 {
|
||||
assert(buffer.len >= size);
|
||||
if (size > buffer.len) return error.TarCorruptInput;
|
||||
const buf = buffer[0..size];
|
||||
try self.reader.readNoEof(buf);
|
||||
return nullStr(buf);
|
||||
|
||||
@ -313,6 +313,10 @@ test "tar run Go test cases" {
|
||||
},
|
||||
},
|
||||
},
|
||||
.{
|
||||
.data = @embedFile("testdata/fuzz1.tar"),
|
||||
.err = error.TarCorruptInput,
|
||||
},
|
||||
};
|
||||
|
||||
for (cases) |case| {
|
||||
|
||||
BIN
lib/std/tar/testdata/fuzz1.tar
vendored
Normal file
BIN
lib/std/tar/testdata/fuzz1.tar
vendored
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user