Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LibDeflate"
uuid = "9255714d-24a7-4b30-8ea3-d46a97f7e13b"
authors = ["Jakob Nybo Nissen <jakobnybonissen@gmail.com>"]
version = "0.4.2"
version = "0.4.3"

[deps]
libdeflate_jll = "46979653-d7f6-5232-b59e-dd310c4598de"
Expand Down
2 changes: 1 addition & 1 deletion src/gzip.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function unsafe_parse_gzip_header(
extra = parse_fields!(extra_vector, ptr + index + 2, index + UInt32(2), extra_len)
extra isa LibDeflateError && return extra
index += extra_len + UInt32(2)
index > max_len && return LibDeflateErrors.gzip_extra_too_long
(index - one(index)) > max_len && return LibDeflateErrors.gzip_extra_too_long
end

filename = nothing
Expand Down
11 changes: 10 additions & 1 deletion test/gzip.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ end
header_data[end-2] = 0x01
@test GC.@preserve header_data unsafe_parse_gzip_header(pointer(header_data), UInt(51)) == LibDeflateErrors.gzip_string_not_null_terminated
header_data[end-2] = 0x00

minimal_data = UInt8[0x1f, 0x8b, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0x06, 0x00, 0x42, 0x43, 0x02, 0x00, 0x10, 0x20
]
(header_len, header) = parse_gzip_header(minimal_data)
@test header_len == 18
ex = only(header.extra)
@test ex.tag == (0x42, 0x43)
@test ex.data == 17:18
end


Expand Down Expand Up @@ -154,4 +163,4 @@ complex_test_case = vcat(header_data, UInt8[
res = gzip_decompress!(decompressor, outdata, complex_test_case)
test_header_example(complex_test_case, res.header)
@test res.len == 11
end
end