Fixed truncation check, so 100 char names get GNU extension support when enabled
commitf6c704837da8d5781c4938a94a89b9239231548f
authorChris Frey <cdfrey@foursquare.net>
Thu, 22 Dec 2011 22:08:28 +0000 (22 17:08 -0500)
committerChris Frey <cdfrey@foursquare.net>
Thu, 22 Dec 2011 22:08:28 +0000 (22 17:08 -0500)
treeec114e6c4a57e960700ba71e6ebe046cd1f423ce
parent11df82507d6c1b6f9630eb410ddd2d3414e80797
Fixed truncation check, so 100 char names get GNU extension support when enabled

Reported by Barrie Walker as follows:

I've experienced a problem with 1.2.11 where a name or link is exactly
100 characters.

When not using TAR_GNU name/linknames longer than 99 characters are
simply truncated to 99 characters (+1 for the NUL makes T_NAMELEN (=
100)). Any overflow is lost - fair enough.

Using TAR_GNU, name/linknames longer than 99 characters are still
truncated to 99 characters but the full string is placed in the
gnu_longname/gnu_longlink fields.
However the gnu_longname/gnu_longlink fields are populated only when a
name/linkname would be truncated.

The bug is that the check to see whether there will be truncation
compares the length against T_NAMELEN rather than T_NAMELEN-1.

The fix is simply, in lines 85 and 123 of encode.c, to change T_NAMELEN
to T_NAMELEN-1.
lib/encode.c