| ... | ... | @@ -155,7 +155,7 @@ pub const Header = struct { |
| 155 | 155 | // If the leading byte is 0x80 (128), the non-leading bytes of the |
| 156 | 156 | // field are concatenated in big-endian order. |
| 157 | 157 | if (raw[0] == 0x80) { |
| 158 | | if (raw[1] + raw[2] + raw[3] != 0) return error.TarNumericValueTooBig; |
| 158 | if (raw[1] != 0 or raw[2] != 0 or raw[3] != 0) return error.TarNumericValueTooBig; |
| 159 | 159 | return std.mem.readInt(u64, raw[4..12], .big); |
| 160 | 160 | } |
| 161 | 161 | return try header.octal(start, len); |
| ... | ... | @@ -769,6 +769,7 @@ test "tar header parse size" { |
| 769 | 769 | .{ .in = "\x80\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08", .want = 0x0102030405060708 }, |
| 770 | 770 | .{ .in = "\x80\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09", .err = error.TarNumericValueTooBig }, |
| 771 | 771 | .{ .in = "\x80\x00\x00\x00\x07\x76\xa2\x22\xeb\x8a\x72\x61", .want = 537795476381659745 }, |
| 772 | .{ .in = "\x80\x80\x80\x00\x01\x02\x03\x04\x05\x06\x07\x08", .err = error.TarNumericValueTooBig }, |
| 772 | 773 | |
| 773 | 774 | // // Test base-8 (octal) encoded values. |
| 774 | 775 | .{ .in = "00000000227\x00", .want = 0o227 }, |