Skip to content

Commit

Permalink
Merge pull request #122 from hannesm/minor
Browse files Browse the repository at this point in the history
call marshal_string for hdr_version, revise the OLD GNU MAGIC codepath
  • Loading branch information
reynir committed Mar 23, 2023
2 parents 392b4bf + 61b5bc1 commit 850018d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/tar.ml
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,10 @@ module Header = struct
Cstruct.blit_from_string v 0 buf hdr_magic_off sizeof_hdr_magic

let _get_hdr_version buf =
Cstruct.to_string ~off:hdr_version_off ~len:sizeof_hdr_version buf
unmarshal_string
(Cstruct.to_string ~off:hdr_version_off ~len:sizeof_hdr_version buf)
let set_hdr_version buf v =
let v = marshal_string v sizeof_hdr_version in
Cstruct.blit_from_string v 0 buf hdr_version_off sizeof_hdr_version

let get_hdr_uname buf =
Expand Down Expand Up @@ -556,9 +558,8 @@ module Header = struct
set_hdr_version c "00";
end else begin
(* OLD GNU MAGIC: use "ustar " as magic, and another " " in the version *)
let magic_len = sizeof_hdr_magic + sizeof_hdr_version in
let magic = marshal_string "ustar " magic_len in
Cstruct.blit_from_string magic 0 c hdr_magic_off magic_len
set_hdr_magic c "ustar ";
set_hdr_version c " ";
end;
set_hdr_uname c x.uname;
set_hdr_gname c x.gname;
Expand Down

0 comments on commit 850018d

Please sign in to comment.