]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blob - pkgs/tar/patches/tar-1.25-sparse-names.patch
Remove legacy build system.
[people/ms/ipfire-3.x.git] / pkgs / tar / patches / tar-1.25-sparse-names.patch
1 From 3f7aebf6e15d2ee39f55528cc9f423b330e68272 Mon Sep 17 00:00:00 2001
2 From: Sergey Poznyakoff <gray@gnu.org.ua>
3 Date: Sat, 27 Nov 2010 14:35:08 +0200
4 Subject: [PATCH] Correctly store long sparse file names in PAX archives.
5
6 * src/sparse.c (pax_dump_header_1): Make sure the created header name is
7 shorter than NAME_FIELD_SIZE bytes.
8 * tests/sparse04.at: New testcase.
9 * tests/Makefile.am (TESTSUITE_AT): Add sparse04.at.
10 * tests/testsuite.at: Include sparse04.at.
11 * NEWS: Update.
12 ---
13 src/sparse.c | 9 ++++++---
14 tests/Makefile.am | 1 +
15 tests/sparse04.at | 47 +++++++++++++++++++++++++++++++++++++++++++++++
16 tests/testsuite.at | 1 +
17 4 files changed, 55 insertions(+), 3 deletions(-)
18 create mode 100644 tests/sparse04.at
19
20 diff --git a/src/sparse.c b/src/sparse.c
21 index 9680b60..696773f 100644
22 --- a/src/sparse.c
23 +++ b/src/sparse.c
24 @@ -991,7 +991,7 @@ pax_dump_header_1 (struct tar_sparse_file *file)
25 off_t size = 0;
26 struct sp_array *map = file->stat_info->sparse_map;
27 char *save_file_name = file->stat_info->file_name;
28 -
29 +
30 #define COPY_STRING(b,dst,src) do \
31 { \
32 char *endp = b->buffer + BLOCKSIZE; \
33 @@ -1029,8 +1029,11 @@ pax_dump_header_1 (struct tar_sparse_file *file)
34 xheader_store ("GNU.sparse.name", file->stat_info, NULL);
35 xheader_store ("GNU.sparse.realsize", file->stat_info, NULL);
36
37 - file->stat_info->file_name = xheader_format_name (file->stat_info,
38 - "%d/GNUSparseFile.%p/%f", 0);
39 + file->stat_info->file_name =
40 + xheader_format_name (file->stat_info, "GNUSparseFile.%p/%f", 0);
41 + /* Make sure the created header name is shorter than NAME_FIELD_SIZE: */
42 + if (strlen (file->stat_info->file_name) > NAME_FIELD_SIZE)
43 + file->stat_info->file_name[NAME_FIELD_SIZE] = 0;
44
45 blk = start_header (file->stat_info);
46 /* Store the effective (shrunken) file size */
47 diff --git a/tests/Makefile.am b/tests/Makefile.am
48 index 12e8c1b..b14b40a 100644
49 --- a/tests/Makefile.am
50 +++ b/tests/Makefile.am
51 @@ -145,6 +145,7 @@ TESTSUITE_AT = \
52 sparse01.at\
53 sparse02.at\
54 sparse03.at\
55 + sparse04.at\
56 sparsemv.at\
57 sparsemvp.at\
58 spmvp00.at\
59 diff --git a/tests/sparse04.at b/tests/sparse04.at
60 new file mode 100644
61 index 0000000..4d41be7
62 --- /dev/null
63 +++ b/tests/sparse04.at
64 @@ -0,0 +1,47 @@
65 +# Process this file with autom4te to create testsuite. -*- Autotest -*-
66 +#
67 +# Test suite for GNU tar.
68 +# Copyright (C) 2010 Free Software Foundation, Inc.
69 +#
70 +# This program is free software; you can redistribute it and/or modify
71 +# it under the terms of the GNU General Public License as published by
72 +# the Free Software Foundation; either version 3, or (at your option)
73 +# any later version.
74 +#
75 +# This program is distributed in the hope that it will be useful,
76 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
77 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
78 +# GNU General Public License for more details.
79 +#
80 +# You should have received a copy of the GNU General Public License
81 +# along with this program; if not, write to the Free Software
82 +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
83 +# 02110-1301, USA.
84 +
85 +AT_SETUP([storing long sparse file names])
86 +AT_KEYWORDS([sparse sparse04])
87 +
88 +# Description: Tar versions from 1.15.92 to 1.25 would incorrectly
89 +# store sparse file names longer than 100 characters in pax mode.
90 +# Namely, the `path' keyword of the produced PAX header would contain the
91 +# crafted name of the header itself, instead of that of the file.
92 +# Reported by: Kamil Dudka <kdudka@redhat.com>
93 +# References: <201011250026.44908.kdudka@redhat.com>,
94 +# http://lists.gnu.org/archive/html/bug-tar/2010-11/msg00099.html
95 +
96 +m4_define([NAME_111],
97 + [123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960])
98 +
99 +AT_TAR_CHECK([
100 +genfile --sparse --file NAME_111 --block-size 512 8M A || AT_SKIP_TEST
101 +tar -c --sparse --posix NAME_111 | tar t
102 +],
103 +[0],
104 +[NAME_111
105 +],
106 +[],
107 +[],
108 +[],
109 +[pax])
110 +
111 +AT_CLEANUP
112 diff --git a/tests/testsuite.at b/tests/testsuite.at
113 index d18b16e..6f06417 100644
114 --- a/tests/testsuite.at
115 +++ b/tests/testsuite.at
116 @@ -223,6 +223,7 @@ m4_include([shortrec.at])
117 m4_include([sparse01.at])
118 m4_include([sparse02.at])
119 m4_include([sparse03.at])
120 +m4_include([sparse04.at])
121 m4_include([sparsemv.at])
122 m4_include([spmvp00.at])
123 m4_include([spmvp01.at])
124 --
125 1.7.3.2
126