mirror of
https://git.savannah.gnu.org/git/tar.git
synced 2026-08-20 08:16:02 +00:00
tar: ignore nonzero sizes in hard links etc
Problem reported by Antonio Teixeira. * src/list.c (read_header): When POSIX says a size field must be zero or does not represent a data count, treat it as zero. * tests/extrac32.at: Update to match new behavior. We now treat hard link sizes as zero even when the size fields are nonzero, and this means the “injected” file is treated as valid regardless of whether we list or extract. * tests/extrac34.at: New test. * tests/Makefile.am (TESTSUITE_AT), tests/testsuite.at: Add it.
This commit is contained in:
+16
@@ -535,6 +535,22 @@ read_header (union block **return_block, struct tar_stat_info *info,
|
||||
struct posix_header const *h = &header->header;
|
||||
char namebuf[sizeof h->prefix + 1 + NAME_FIELD_SIZE + 1];
|
||||
|
||||
switch (h->typeflag)
|
||||
{
|
||||
/* For these file types, although POSIX does not specify the
|
||||
meaning of the size, it does say there should be no data,
|
||||
so treat the size as zero. */
|
||||
case BLKTYPE: case CHRTYPE: case FIFOTYPE:
|
||||
|
||||
/* For these file types, POSIX requires that the size be zero.
|
||||
Be generous and accept any size as zero, as some
|
||||
nonconforming programs generate nonzero size fields along
|
||||
with no data. */
|
||||
case LNKTYPE: case SYMTYPE:
|
||||
|
||||
info->stat.st_size = 0;
|
||||
}
|
||||
|
||||
free (recent_long_name);
|
||||
|
||||
if (next_long_name)
|
||||
|
||||
Reference in New Issue
Block a user