Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tar.Header.make and PAX #142

Open
reynir opened this issue Feb 5, 2024 · 0 comments
Open

Tar.Header.make and PAX #142

reynir opened this issue Feb 5, 2024 · 0 comments

Comments

@reynir
Copy link
Member

reynir commented Feb 5, 2024

The Tar.Header.make function checks the size required for the file size, uid and gid and creates an extended header if needed. This could as well check the file name size and other fields.

ocaml-tar/lib/tar.ml

Lines 466 to 489 in ef66a98

(** Helper function to make a simple header *)
let make ?(file_mode=0o400) ?(user_id=0) ?(group_id=0) ?(mod_time=0L) ?(link_indicator=Link.Normal) ?(link_name="") ?(uname="") ?(gname="") ?(devmajor=0) ?(devminor=0) file_name file_size =
(* If some fields are too big, we must use a pax header *)
let need_pax_header =
Int64.unsigned_compare file_size 0o077777777777L > 0
|| user_id > 0x07777777
|| group_id > 0x07777777 in
let extended =
if need_pax_header
then Some (Extended.make ~file_size ~user_id ~group_id ())
else None in
{ file_name;
file_mode;
user_id;
group_id;
file_size;
mod_time;
link_indicator;
link_name;
uname;
gname;
devmajor;
devminor;
extended }

A problem, though, is that the compatibility level is not considered, and in our writer we don't check the compatibility level before writing the extended header. This means we can set compatibility level to V7 but still get PAX extended headers. There is as well a discrepancy how we handle this for GNU compatibility level -- there we synthesize the GNU LongLink in the writer instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant