sptrcreat.at 2.0 KB

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