Thread (7 messages) flat view 7 messages, 3 authors, 2019-08-17

Re: [PATCH 2/4] archive-tar: fix pax extended header length calculation

From: Eric Sunshine <hidden>
Date: 2019-08-17 18:05:34

On Sat, Aug 17, 2019 at 12:24 PM René Scharfe [off-list ref] wrote:
A pax extended header records starts with a decimal number.  Its value
s/records/record/
is the length of the whole record, including its own length.

The calculation of that number if strbuf_append_ext_header() is off by
s/if/in/
one in case the length of the rest is close to a higher order of
magnitude.  This affects paths and link targets a bit shorter than 1000,
10000, 100000 etc. characters -- paths with a length of up to 100 fit
into the tar header and don't need a pax extended header.

The mistake has been present since the function was added by ae64bbc18c
("tar-tree: Introduce write_entry()", 2006-03-25).

Account for digits added to len during the loop and keep incrementing
until we have enough space for len and the rest.  The crucial change is
to check against the current value of len before each iteration, instead
of against its value before the loop.

Signed-off-by: René Scharfe <redacted>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help