Fix more -t/-x discrepancies

Problem reported by Guillermo de Angel in:
https://lists.gnu.org/r/bug-tar/2026-03/msg00007.html
* THANKS: Add him, and sort.
* src/extract.c (extract_dir, extract_file):
* src/incremen.c (purge_directory):
Do not call skip_member, as the caller now does that, and does it
more reliably.
* src/extract.c (extract_file):
Mark file as skipped when we’ve read it.
(extract_archive): Always call skip_member after extracting,
as it suppresses the skip as needed.
* src/incremen.c (try_purge_directory): Remove; no longer
needed.  Move internals to purge_directory.
* src/list.c (read_header): Do not treat LNKTYPE header as having
size zero, as it can be nonzero (e.g., ‘pax -o linkdata’).
Set info->skipped field according to how the header was read.
(member_is_dir): Remove; no longer needed.
(skim_member): Skip directory data too, unless it’s already been
skipped (i.e., read).
* tests/extrac32.at: New file.
* tests/Makefile.am (TESTSUITE_AT):
* tests/testsuite.at:
Add it.
* tests/skipdir.at (skip directory members):
Fix test to match the correct behavior.
This fixes a bug introduced in commit
b009124ffd
dated 2025-05-12 17:17:21 +0300.
This commit is contained in:
Paul Eggert
2026-03-22 12:23:55 -07:00
parent e06a880a91
commit b8d8a61b25
8 changed files with 94 additions and 84 deletions
+1
View File
@@ -141,6 +141,7 @@ TESTSUITE_AT = \
extrac29.at\
extrac30.at\
extrac31.at\
extrac32.at\
filerem01.at\
filerem02.at\
filerem03.at\
+47
View File
@@ -0,0 +1,47 @@
# Check for file injection bug with symlinks. -*- Autotest -*-
# Copyright 2026 Free Software Foundation, Inc.
# This file is part of GNU tar.
# GNU tar is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# GNU tar is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Thanks to Guillermo de Angel for the bug report and test cases; see:
# https://lists.gnu.org/r/bug-tar/2026-03/msg00007.html
AT_SETUP([skip file injection])
AT_KEYWORDS([injection])
AT_DATA([archive.in],
[/Td6WFoAAATm1rRGBMDbAYAcIQEcAAAAAAAAACYr+9LgDf8A010AMZhKvfVdtHe4Rxjj7M03ek97
UgeKfJ0ORqYg0XDFntWxdTH4PYrTOo9CoqBrnTM2NcwFBrRVr7aFwdd56vddyAw2QGDjxgNexDU3
ImTi/+z8ZOLMi/+AybdEpd5aA/M9Maa+8tQ84bySzSAwrmxMWJJ6W9IKvsqfiRa3TrD51v44PZU/
KLVKpocS56n/O3g+b+hiZwaysR0eLO+tiU8FB/e3PEq3vTtDFVi/YfZMieBWSzomSX9eF13K1yPY
UuWgp7VokXqduL0YGNVV40MTPG9oAAAApD6mpajengIAAfcBgBwAAOM4xw6xxGf7AgAAAAAEWVo=
])
AT_CHECK([base64 --help >/dev/null 2>&1 || AT_SKIP_TEST
xz --help >/dev/null 2>&1 || AT_SKIP_TEST
base64 -d < archive.in | xz -c -d > archive.tar
])
cp archive.tar /tmp
AT_CHECK([tar tf archive.tar],
[0],
[carrier_entry
marker.txt
])
AT_CHECK([tar xvf archive.tar],
[0],
[carrier_entry
marker.txt
])
AT_CLEANUP
+1 -5
View File
@@ -42,15 +42,11 @@ base64 -d < archive.in | xz -c -d > archive.tar
AT_CHECK([tar tf archive.tar],
[0],
[owo1/
owo2/
])
AT_CHECK([tar vxf archive.tar],
[0],
[owo1/
owo2/
])
AT_CHECK([tar -xvf archive.tar --exclude owo1],
[0],
[owo2/
])
[0])
AT_CLEANUP
+1
View File
@@ -358,6 +358,7 @@ m4_include([extrac28.at])
m4_include([extrac29.at])
m4_include([extrac30.at])
m4_include([extrac31.at])
m4_include([extrac32.at])
m4_include([backup01.at])