| 1 |
# Process this file with autom4te to create testsuite. -*- Autotest -*- |
| 2 |
|
| 3 |
# Test suite for GNU tar. |
| 4 |
# Copyright 2018-2023 Free Software Foundation, Inc. |
| 5 |
|
| 6 |
# This file is part of GNU tar. |
| 7 |
|
| 8 |
# GNU tar is free software; you can redistribute it and/or modify |
| 9 |
# it under the terms of the GNU General Public License as published by |
| 10 |
# the Free Software Foundation; either version 3 of the License, or |
| 11 |
# (at your option) any later version. |
| 12 |
|
| 13 |
# GNU tar is distributed in the hope that it will be useful, |
| 14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
# GNU General Public License for more details. |
| 17 |
|
| 18 |
# You should have received a copy of the GNU General Public License |
| 19 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 |
|
| 21 |
# Tar up to 1.30 would loop endlessly if a sparse file had been truncated |
| 22 |
# while being archived (with --sparse flag). |
| 23 |
# |
| 24 |
# The bug has been assigned id CVE-2018-20482 (on the grounds that it is a |
| 25 |
# denial of service possibility). |
| 26 |
# |
| 27 |
# Reported by: Chris Siebenmann <[email protected]> |
| 28 |
# References: <[email protected]>, |
| 29 |
# <http://lists.gnu.org/archive/html/bug-tar/2018-12/msg00023.html> |
| 30 |
# <https://utcc.utoronto.ca/~cks/space/blog/sysadmin/TarFindingTruncateBug> |
| 31 |
# <https://nvd.nist.gov/vuln/detail/CVE-2018-20482> |
| 32 |
|
| 33 |
AT_SETUP([sparse file truncated while archiving]) |
| 34 |
AT_KEYWORDS([truncate filechange sparse sptr sptrcreat]) |
| 35 |
|
| 36 |
AT_TAR_CHECK([ |
| 37 |
genfile --sparse --block-size=1024 --file foo \ |
| 38 |
0 ABCDEFGHIJ 1M ABCDEFGHIJ 10M ABCDEFGHIJ 200M ABCDEFGHIJ || AT_SKIP_TEST |
| 39 |
genfile --file baz |
| 40 |
genfile --run --checkpoint 3 --length 200m --truncate foo -- \ |
| 41 |
tar --sparse -vcf bar foo baz |
| 42 |
echo Exit status: $? |
| 43 |
echo separator |
| 44 |
genfile --file foo --seek 200m --length 11575296 --pattern=zeros |
| 45 |
tar dvf bar | sed '/foo: Mod time differs/d'], |
| 46 |
[0], |
| 47 |
[foo |
| 48 |
baz |
| 49 |
Exit status: 1 |
| 50 |
separator |
| 51 |
foo |
| 52 |
baz |
| 53 |
], |
| 54 |
[tar: foo: File shrank by 11575296 bytes; padding with zeros |
| 55 |
], |
| 56 |
[],[],[posix, gnu, oldgnu]) |
| 57 |
|
| 58 |
AT_CLEANUP |