Closed reynir closed 7 months ago
Reproducing snippet:
let cs = Cstruct.create 1024 in
Tar.Header.make "test" 5L |> Tar.Header.marshal cs;
(* Blit "Hello, World!" well outside the tar header *)
Cstruct.blit_from_string "Hello, World!" 0 cs 800 13;
Tar.Header.unmarshal cs
This is also an issue in Tar.Header.unmarshal
on 2.6.0. In main branch we check the input buffer is Tar.Header.length
long and thus does not allow this behavior.
Now I am struggling to write a reproducing example, but I had
Tar.Header.marshal buf hdr
which produced a new checksum every time even if the file was the same. Then I rewrote it toTar.Hheader.marshal (Cstruct.sub buf 0 Tar.Header.length) hdr
and the checksum was correct. It was a very long buffer with some random data near the end. It seems the header checksum is computed over the whole buffer, but we should only consider the first 512 bytes (the actual header).This was observed in tar.2.6.0, but it seems it's an issue with main branch judging from the source code.