4
0

incr08.at 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # Process this file with autom4te to create testsuite. -*- Autotest -*-
  2. # Test suite for GNU tar.
  3. # Copyright 2013-2023 Free Software Foundation, Inc.
  4. #
  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. #
  10. # GNU tar is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. # Description: In tar 1.26 listed-incremental with -C and absolute path
  18. # would malfunction under certain conditions due to buggy filename
  19. # normalization.
  20. #
  21. # The value returned by normalize_filename() is used to populate the "caname"
  22. # field in both the "directory" structure in incremen.c and the "name"
  23. # structure in names.c, and in both cases that field is then used in the
  24. # "hash" and "compare" functions for the related hash tables. Thus, the
  25. # fact that the returned value doesn't reflect the operation of previous
  26. # "-C" options means that it's possible for two different directories to
  27. # be given the same "caname" value in the hashed structure and thus end up
  28. # being confused with each other.
  29. #
  30. # The bug is triggered when dumping both relative paths after -C and
  31. # absolute paths that match the process' current working directory.
  32. #
  33. # Reported by: Nathan Stratton Treadway <[email protected]>
  34. # References: <[email protected]>,
  35. # http://lists.gnu.org/archive/html/bug-tar/2013-09/msg00034.html
  36. AT_SETUP([filename normalization])
  37. AT_KEYWORDS([incremental create incr08 chdir])
  38. AT_TAR_WITH_HOOK(
  39. [AT_CHECK([
  40. DIR=`pwd`/gnu/tartest
  41. sed "s|$DIR|ABSPATH|" stdout
  42. ],
  43. [0],
  44. [A
  45. .
  46. ./foo
  47. ./foo/subdir
  48. ./foo/subdir/dir1
  49. ./subdir
  50. ./subdir/dir2
  51. B
  52. ./
  53. ./subdir/
  54. ./subdir/dir1/
  55. ABSPATH/
  56. ABSPATH/subdir/
  57. ABSPATH/subdir/dir2/
  58. ])
  59. AT_CHECK([
  60. DIR=`pwd`/gnu/tartest
  61. sed "/tar: Removing leading \`\/*\/' from/d;s|$DIR|ABSPATH|" stderr],
  62. [0],
  63. [A
  64. B
  65. tar: .: Directory is new
  66. tar: ./subdir: Directory is new
  67. tar: ./subdir/dir1: Directory is new
  68. tar: ABSPATH: Directory is new
  69. tar: ABSPATH/subdir: Directory is new
  70. tar: ABSPATH/subdir/dir2: Directory is new
  71. ])],
  72. [AT_TAR_CHECK([
  73. AT_CHECK_TIMESTAMP
  74. AT_SORT_PREREQ
  75. mkdir tartest
  76. cd tartest
  77. mkdir foo
  78. mkdir foo/subdir
  79. mkdir foo/subdir/dir1
  80. mkdir subdir
  81. mkdir subdir/dir2
  82. decho A
  83. find .|sort
  84. decho B
  85. DIR=`pwd`
  86. tar -cvf ../foo.tar --listed-incremental=../foo.snar -C foo . $DIR
  87. ],
  88. [0],
  89. [stdout],
  90. [stderr],[],[],[gnu])])
  91. AT_CLEANUP