update to 1.32
This commit is contained in:
parent
45224c6883
commit
a87ba75c02
@ -1,83 +0,0 @@
|
||||
From 577dc345653947a31b2841167dc1a9be0e44e043 Mon Sep 17 00:00:00 2001
|
||||
From: Pavel Raiskup <praiskup@redhat.com>
|
||||
Date: Tue, 31 Jul 2018 12:06:09 +0300
|
||||
Subject: [PATCH 20/58] Avoid some resource leaks
|
||||
|
||||
* src/incremen.c (store_rename): Free temp_name, leaked before for
|
||||
each renamed directory with --listed-incremental.
|
||||
* src/transform.c (add_literal_segment): Tighten arguments by
|
||||
const.
|
||||
(parse_transform_expr): Free 'str', leaked storage for each
|
||||
--transform option before.
|
||||
* src/utf8.c (utf8_convert): Deallocate buffer for failed iconv()
|
||||
call so callers don't have to.
|
||||
---
|
||||
src/incremen.c | 1 +
|
||||
src/transform.c | 3 ++-
|
||||
src/utf8.c | 9 ++++++---
|
||||
3 files changed, 9 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/incremen.c b/src/incremen.c
|
||||
index ca611f6..7c26eb8 100644
|
||||
--- a/src/incremen.c
|
||||
+++ b/src/incremen.c
|
||||
@@ -915,6 +915,7 @@ store_rename (struct directory *dir, struct obstack *stk)
|
||||
obstack_code_rename (stk, p->orig->name, p->name);
|
||||
|
||||
obstack_code_rename (stk, "", prev->name);
|
||||
+ free (temp_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/src/transform.c b/src/transform.c
|
||||
index 3fae3c0..6ef0da6 100644
|
||||
--- a/src/transform.c
|
||||
+++ b/src/transform.c
|
||||
@@ -101,7 +101,7 @@ add_segment (struct transform *tf)
|
||||
}
|
||||
|
||||
static void
|
||||
-add_literal_segment (struct transform *tf, char *str, char *end)
|
||||
+add_literal_segment (struct transform *tf, const char *str, const char *end)
|
||||
{
|
||||
size_t len = end - str;
|
||||
if (len)
|
||||
@@ -403,6 +403,7 @@ parse_transform_expr (const char *expr)
|
||||
cur++;
|
||||
}
|
||||
add_literal_segment (tf, beg, cur);
|
||||
+ free(str);
|
||||
|
||||
return p;
|
||||
}
|
||||
diff --git a/src/utf8.c b/src/utf8.c
|
||||
index a018ce0..168d636 100644
|
||||
--- a/src/utf8.c
|
||||
+++ b/src/utf8.c
|
||||
@@ -68,7 +68,6 @@ utf8_convert (bool to_utf, char const *input, char **output)
|
||||
char *ob;
|
||||
size_t inlen;
|
||||
size_t outlen;
|
||||
- size_t rc;
|
||||
iconv_t cd = utf8_init (to_utf);
|
||||
|
||||
if (cd == 0)
|
||||
@@ -83,9 +82,13 @@ utf8_convert (bool to_utf, char const *input, char **output)
|
||||
outlen = inlen * MB_LEN_MAX + 1;
|
||||
ob = *output = xmalloc (outlen);
|
||||
ib = (char ICONV_CONST *) input;
|
||||
- rc = iconv (cd, &ib, &inlen, &ob, &outlen);
|
||||
+ if (iconv (cd, &ib, &inlen, &ob, &outlen) == -1)
|
||||
+ {
|
||||
+ free (*output);
|
||||
+ return false;
|
||||
+ }
|
||||
*ob = 0;
|
||||
- return rc != -1;
|
||||
+ return true;
|
||||
}
|
||||
|
||||
|
||||
--
|
||||
2.19.1
|
||||
|
||||
29
Bugfix.patch
29
Bugfix.patch
@ -1,29 +0,0 @@
|
||||
From ea3aea06f1da077dbb4092672dc7e8768ae4f84e Mon Sep 17 00:00:00 2001
|
||||
From: Sergey Poznyakoff <gray@gnu.org>
|
||||
Date: Fri, 21 Dec 2018 13:42:29 +0200
|
||||
Subject: [PATCH 37/58] Bugfix
|
||||
|
||||
Bug reported in
|
||||
http://lists.gnu.org/archive/html/bug-tar/2018-12/msg00014.html
|
||||
|
||||
* src/names.c (collect_and_sort_names): Fix iteration over namelist.
|
||||
---
|
||||
src/names.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/names.c b/src/names.c
|
||||
index d3728d8..025b682 100644
|
||||
--- a/src/names.c
|
||||
+++ b/src/names.c
|
||||
@@ -1857,7 +1857,7 @@ collect_and_sort_names (void)
|
||||
|
||||
if (listed_incremental_option)
|
||||
{
|
||||
- for (name = namelist; name && name->name[0] == 0; name++)
|
||||
+ for (name = namelist; name && name->name[0] == 0; name = name->next)
|
||||
;
|
||||
if (name)
|
||||
append_incremental_renames (name->directory);
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -1,75 +0,0 @@
|
||||
From 3c2a2cd94d3b062aa5bf850b82364039ec9c6029 Mon Sep 17 00:00:00 2001
|
||||
From: Sergey Poznyakoff <gray@gnu.org>
|
||||
Date: Fri, 21 Dec 2018 14:18:14 +0200
|
||||
Subject: [PATCH 38/58] Disallow modifications to the global pax extended
|
||||
header in update mode.
|
||||
|
||||
Updating global headers in update mode is not possible, because:
|
||||
|
||||
1) If the original archive was not in PAX format, writing the
|
||||
global header would overwrite first member header (and eventually
|
||||
data blocks) in the archive.
|
||||
2) Otherwise, using the --pax-option can make the updated header
|
||||
occupy more blocks than the original one, which would lead to the
|
||||
same effect as in 1.
|
||||
|
||||
This also fixes
|
||||
http://lists.gnu.org/archive/html/bug-tar/2018-12/msg00007.html
|
||||
|
||||
* src/xheader.c (xheader_forbid_global): New function.
|
||||
* src/common.h (xheader_forbid_global): New prototype.
|
||||
* src/update.c (update_archive): Use xheader_forbid_global, instead
|
||||
of trying to write global extended header record.
|
||||
---
|
||||
src/common.h | 1 +
|
||||
src/update.c | 2 +-
|
||||
src/xheader.c | 8 ++++++++
|
||||
3 files changed, 10 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/common.h b/src/common.h
|
||||
index 32e6f8b..885169f 100644
|
||||
--- a/src/common.h
|
||||
+++ b/src/common.h
|
||||
@@ -836,6 +836,7 @@ void xheader_store (char const *keyword, struct tar_stat_info *st,
|
||||
void xheader_read (struct xheader *xhdr, union block *header, off_t size);
|
||||
void xheader_write (char type, char *name, time_t t, struct xheader *xhdr);
|
||||
void xheader_write_global (struct xheader *xhdr);
|
||||
+void xheader_forbid_global (void);
|
||||
void xheader_finish (struct xheader *hdr);
|
||||
void xheader_destroy (struct xheader *hdr);
|
||||
char *xheader_xhdr_name (struct tar_stat_info *st);
|
||||
diff --git a/src/update.c b/src/update.c
|
||||
index 2f823e4..4aa4ac6 100644
|
||||
--- a/src/update.c
|
||||
+++ b/src/update.c
|
||||
@@ -111,7 +111,7 @@ update_archive (void)
|
||||
|
||||
name_gather ();
|
||||
open_archive (ACCESS_UPDATE);
|
||||
- buffer_write_global_xheader ();
|
||||
+ xheader_forbid_global ();
|
||||
|
||||
while (!found_end)
|
||||
{
|
||||
diff --git a/src/xheader.c b/src/xheader.c
|
||||
index e938502..010cab7 100644
|
||||
--- a/src/xheader.c
|
||||
+++ b/src/xheader.c
|
||||
@@ -469,6 +469,14 @@ xheader_write_global (struct xheader *xhdr)
|
||||
}
|
||||
}
|
||||
|
||||
+/* Forbid modifications of the global extended header */
|
||||
+void
|
||||
+xheader_forbid_global (void)
|
||||
+{
|
||||
+ if (keyword_global_override_list)
|
||||
+ USAGE_ERROR ((0, 0, _("can't update global extended header record")));
|
||||
+}
|
||||
+
|
||||
void
|
||||
xheader_xattr_init (struct tar_stat_info *st)
|
||||
{
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -1,465 +0,0 @@
|
||||
From fd555fc06bfb4eae3eb48fbc150d20a4dda0d150 Mon Sep 17 00:00:00 2001
|
||||
From: Sergey Poznyakoff <gray@gnu.org>
|
||||
Date: Thu, 27 Dec 2018 17:48:57 +0200
|
||||
Subject: [PATCH] Fixed a denial of service when the '--sparse' option
|
||||
mishandles file shrinkage during read access(CVE-2018-20482)
|
||||
https://github.com/praiskup/tar/commit/c15c42ccd1e2377945fd0414eca1a49294bff454
|
||||
|
||||
Signed-off-by: fangyufa1 <fangyufa1@huawei.com>
|
||||
---
|
||||
NEWS | 32 +++++++++++++++++-
|
||||
src/sparse.c | 82 +++++++++++++++++++++++++++++----------------
|
||||
tests/Makefile.am | 5 ++-
|
||||
tests/sptrcreat.at | 62 ++++++++++++++++++++++++++++++++++
|
||||
tests/sptrdiff00.at | 55 ++++++++++++++++++++++++++++++
|
||||
tests/sptrdiff01.at | 55 ++++++++++++++++++++++++++++++
|
||||
tests/testsuite.at | 5 ++-
|
||||
7 files changed, 264 insertions(+), 32 deletions(-)
|
||||
create mode 100644 tests/sptrcreat.at
|
||||
create mode 100644 tests/sptrdiff00.at
|
||||
create mode 100644 tests/sptrdiff01.at
|
||||
|
||||
diff --git a/NEWS b/NEWS
|
||||
index cd15fa1..283c376 100644
|
||||
--- a/NEWS
|
||||
+++ b/NEWS
|
||||
@@ -1,7 +1,37 @@
|
||||
-GNU tar NEWS - User visible changes. 2017-12-17
|
||||
+GNU tar NEWS - User visible changes. 2018-12-27
|
||||
Please send GNU tar bug reports to <bug-tar@gnu.org>
|
||||
|
||||
|
||||
+version 1.30.90 (Git)
|
||||
+
|
||||
+* Fix heap-buffer-overrun with --one-top-level.
|
||||
+Bug introduced with the addition of that option in 1.28.
|
||||
+
|
||||
+* Support for zstd compression
|
||||
+
|
||||
+New option '--zstd' instructs tar to use zstd as compression program.
|
||||
+When listing, extractng and comparing, zstd compressed archives are
|
||||
+recognized automatically.
|
||||
+When '-a' option is in effect, zstd compression is selected if the
|
||||
+destination archive name ends in '.zst' or '.tzst'.
|
||||
+
|
||||
+* The -K option interacts properly with member names given in the command line
|
||||
+
|
||||
+Names of members to extract can be specified along with the "-K NAME"
|
||||
+option. In this case, tar will extract NAME and those of named members
|
||||
+that appear in the archive after it, which is consistent with the
|
||||
+semantics of the option.
|
||||
+
|
||||
+Previous versions of tar extracted NAME, those of named members that
|
||||
+appeared before it, and everything after it.
|
||||
+
|
||||
+* Fix CVE-2018-20482
|
||||
+
|
||||
+When creating archives with the --sparse option, previous versions of
|
||||
+tar would loop endlessly if a sparse file had been truncated while
|
||||
+being archived.
|
||||
+
|
||||
+
|
||||
version 1.30 - Sergey Poznyakoff, 2017-12-17
|
||||
|
||||
* Member names containing '..' components are now skipped when extracting.
|
||||
diff --git a/src/sparse.c b/src/sparse.c
|
||||
index 6ec069d..726facd 100644
|
||||
--- a/src/sparse.c
|
||||
+++ b/src/sparse.c
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Functions for dealing with sparse files
|
||||
|
||||
- Copyright 2003-2007, 2010, 2013-2017 Free Software Foundation, Inc.
|
||||
+ Copyright 2003-2007, 2010, 2013-2018 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
@@ -428,16 +428,30 @@ sparse_dump_region (struct tar_sparse_file *file, size_t i)
|
||||
bufsize);
|
||||
return false;
|
||||
}
|
||||
- if (bytes_read == 0)
|
||||
- {
|
||||
- char buf[UINTMAX_STRSIZE_BOUND];
|
||||
- FATAL_ERROR ((0, 0,
|
||||
- ngettext ("%s: File shrank by %s byte",
|
||||
- "%s: File shrank by %s bytes",
|
||||
- bytes_left),
|
||||
- quotearg_colon (file_name),
|
||||
- offtostr (bytes_left, buf)));
|
||||
- }
|
||||
+ else if (bytes_read == 0)
|
||||
+ {
|
||||
+ char buf[UINTMAX_STRSIZE_BOUND];
|
||||
+ struct stat st;
|
||||
+ size_t n;
|
||||
+ if (fstat (file->fd, &st) == 0)
|
||||
+ n = file->stat_info->stat.st_size - st.st_size;
|
||||
+ else
|
||||
+ n = file->stat_info->stat.st_size
|
||||
+ - (file->stat_info->sparse_map[i].offset
|
||||
+ + file->stat_info->sparse_map[i].numbytes
|
||||
+ - bytes_left);
|
||||
+
|
||||
+ WARNOPT (WARN_FILE_SHRANK,
|
||||
+ (0, 0,
|
||||
+ ngettext ("%s: File shrank by %s byte; padding with zeros",
|
||||
+ "%s: File shrank by %s bytes; padding with zeros",
|
||||
+ n),
|
||||
+ quotearg_colon (file_name),
|
||||
+ STRINGIFY_BIGINT (n, buf)));
|
||||
+ if (! ignore_failed_read_option)
|
||||
+ set_exit_status (TAREXIT_DIFFERS);
|
||||
+ return false;
|
||||
+ }
|
||||
|
||||
memset (blk->buffer + bytes_read, 0, BLOCKSIZE - bytes_read);
|
||||
bytes_left -= bytes_read;
|
||||
@@ -475,9 +489,9 @@ sparse_extract_region (struct tar_sparse_file *file, size_t i)
|
||||
return false;
|
||||
}
|
||||
set_next_block_after (blk);
|
||||
+ file->dumped_size += BLOCKSIZE;
|
||||
count = blocking_write (file->fd, blk->buffer, wrbytes);
|
||||
write_size -= count;
|
||||
- file->dumped_size += count;
|
||||
mv_size_left (file->stat_info->archive_file_size - file->dumped_size);
|
||||
file->offset += count;
|
||||
if (count != wrbytes)
|
||||
@@ -610,20 +624,24 @@ check_sparse_region (struct tar_sparse_file *file, off_t beg, off_t end)
|
||||
offset, rdsize);
|
||||
return false;
|
||||
}
|
||||
-
|
||||
- if (bytes_read == 0
|
||||
- || !zero_block_p (diff_buffer, bytes_read))
|
||||
- {
|
||||
- char begbuf[INT_BUFSIZE_BOUND (off_t)];
|
||||
- const char *msg = bytes_read ? _("File fragment at %s is not a hole")
|
||||
- : _("Hole starting at %s is truncated");
|
||||
-
|
||||
- report_difference (file->stat_info, msg, offtostr (beg, begbuf));
|
||||
- return false;
|
||||
- }
|
||||
+ else if (bytes_read == 0)
|
||||
+ {
|
||||
+ report_difference (file->stat_info, _("Size differs"));
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (!zero_block_p (diff_buffer, bytes_read))
|
||||
+ {
|
||||
+ char begbuf[INT_BUFSIZE_BOUND (off_t)];
|
||||
+ report_difference (file->stat_info,
|
||||
+ _("File fragment at %s is not a hole"),
|
||||
+ offtostr (offset, begbuf));
|
||||
+ return false;
|
||||
+ }
|
||||
|
||||
offset += bytes_read;
|
||||
}
|
||||
+
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -650,6 +668,7 @@ check_data_region (struct tar_sparse_file *file, size_t i)
|
||||
return false;
|
||||
}
|
||||
set_next_block_after (blk);
|
||||
+ file->dumped_size += BLOCKSIZE;
|
||||
bytes_read = safe_read (file->fd, diff_buffer, rdsize);
|
||||
if (bytes_read == SAFE_READ_ERROR)
|
||||
{
|
||||
@@ -660,11 +679,14 @@ check_data_region (struct tar_sparse_file *file, size_t i)
|
||||
rdsize);
|
||||
return false;
|
||||
}
|
||||
- file->dumped_size += bytes_read;
|
||||
+ else if (bytes_read == 0)
|
||||
+ {
|
||||
+ report_difference (¤t_stat_info, _("Size differs"));
|
||||
+ return false;
|
||||
+ }
|
||||
size_left -= bytes_read;
|
||||
mv_size_left (file->stat_info->archive_file_size - file->dumped_size);
|
||||
- if (bytes_read == 0
|
||||
- || memcmp (blk->buffer, diff_buffer, bytes_read))
|
||||
+ if (memcmp (blk->buffer, diff_buffer, bytes_read))
|
||||
{
|
||||
report_difference (file->stat_info, _("Contents differ"));
|
||||
return false;
|
||||
@@ -1229,7 +1251,8 @@ pax_decode_header (struct tar_sparse_file *file)
|
||||
union block *blk;
|
||||
char *p;
|
||||
size_t i;
|
||||
-
|
||||
+ off_t start;
|
||||
+
|
||||
#define COPY_BUF(b,buf,src) do \
|
||||
{ \
|
||||
char *endp = b->buffer + BLOCKSIZE; \
|
||||
@@ -1245,7 +1268,6 @@ pax_decode_header (struct tar_sparse_file *file)
|
||||
if (src == endp) \
|
||||
{ \
|
||||
set_next_block_after (b); \
|
||||
- file->dumped_size += BLOCKSIZE; \
|
||||
b = find_next_block (); \
|
||||
if (!b) \
|
||||
FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); \
|
||||
@@ -1258,8 +1280,8 @@ pax_decode_header (struct tar_sparse_file *file)
|
||||
dst[-1] = 0; \
|
||||
} while (0)
|
||||
|
||||
+ start = current_block_ordinal ();
|
||||
set_next_block_after (current_header);
|
||||
- file->dumped_size += BLOCKSIZE;
|
||||
blk = find_next_block ();
|
||||
if (!blk)
|
||||
FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
|
||||
@@ -1298,6 +1320,8 @@ pax_decode_header (struct tar_sparse_file *file)
|
||||
sparse_add_map (file->stat_info, &sp);
|
||||
}
|
||||
set_next_block_after (blk);
|
||||
+
|
||||
+ file->dumped_size += BLOCKSIZE * (current_block_ordinal () - start);
|
||||
}
|
||||
|
||||
return true;
|
||||
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
||||
index 2d7939d..ac3b6e7 100644
|
||||
--- a/tests/Makefile.am
|
||||
+++ b/tests/Makefile.am
|
||||
@@ -1,6 +1,6 @@
|
||||
# Makefile for GNU tar regression tests.
|
||||
|
||||
-# Copyright 1996-1997, 1999-2001, 2003-2007, 2009, 2012-2015 Free Software
|
||||
+# Copyright 1996-1997, 1999-2001, 2003-2007, 2009, 2012-2018 Free Software
|
||||
|
||||
# This file is part of GNU tar.
|
||||
|
||||
@@ -228,6 +228,9 @@ TESTSUITE_AT = \
|
||||
spmvp00.at\
|
||||
spmvp01.at\
|
||||
spmvp10.at\
|
||||
+ sptrcreat.at\
|
||||
+ sptrdiff00.at\
|
||||
+ sptrdiff01.at\
|
||||
time01.at\
|
||||
time02.at\
|
||||
truncate.at\
|
||||
diff --git a/tests/sptrcreat.at b/tests/sptrcreat.at
|
||||
new file mode 100644
|
||||
index 0000000..8e28f0e
|
||||
--- /dev/null
|
||||
+++ b/tests/sptrcreat.at
|
||||
@@ -0,0 +1,62 @@
|
||||
+# Process this file with autom4te to create testsuite. -*- Autotest -*-
|
||||
+
|
||||
+# Test suite for GNU tar.
|
||||
+# Copyright 2018 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/>.
|
||||
+
|
||||
+# Tar up to 1.30 would loop endlessly if a sparse file had been truncated
|
||||
+# while being archived (with --sparse flag).
|
||||
+#
|
||||
+# The bug has been assigned id CVE-2018-20482 (on the grounds that it is a
|
||||
+# denial of service possibility).
|
||||
+#
|
||||
+# Reported by: Chris Siebenmann <cks.gnutar-01@cs.toronto.edu>
|
||||
+# References: <20181226223948.781EB32008E@apps1.cs.toronto.edu>,
|
||||
+# <http://lists.gnu.org/archive/html/bug-tar/2018-12/msg00023.html>
|
||||
+# <https://utcc.utoronto.ca/~cks/space/blog/sysadmin/TarFindingTruncateBug>
|
||||
+# <https://nvd.nist.gov/vuln/detail/CVE-2018-20482>
|
||||
+
|
||||
+AT_SETUP([sparse file truncated while archiving])
|
||||
+AT_KEYWORDS([truncate filechange sparse sptr sptrcreat])
|
||||
+
|
||||
+AT_TAR_CHECK([
|
||||
+genfile --sparse --block-size=1024 --file foo \
|
||||
+ 0 ABCDEFGHIJ 1M ABCDEFGHIJ 10M ABCDEFGHIJ 200M ABCDEFGHIJ
|
||||
+genfile --file baz
|
||||
+genfile --run --checkpoint 3 --length 200m --truncate foo -- \
|
||||
+ tar --checkpoint=1 \
|
||||
+ --checkpoint-action=echo \
|
||||
+ --checkpoint-action=sleep=1 \
|
||||
+ --sparse -vcf bar foo baz
|
||||
+echo Exit status: $?
|
||||
+echo separator
|
||||
+genfile --file foo --seek 200m --length 11575296 --pattern=zeros
|
||||
+tar dvf bar],
|
||||
+[1],
|
||||
+[foo
|
||||
+baz
|
||||
+Exit status: 1
|
||||
+separator
|
||||
+foo
|
||||
+foo: Mod time differs
|
||||
+baz
|
||||
+],
|
||||
+[tar: foo: File shrank by 11575296 bytes; padding with zeros
|
||||
+],
|
||||
+[],[],[posix, gnu, oldgnu])
|
||||
+
|
||||
+AT_CLEANUP
|
||||
diff --git a/tests/sptrdiff00.at b/tests/sptrdiff00.at
|
||||
new file mode 100644
|
||||
index 0000000..c410561
|
||||
--- /dev/null
|
||||
+++ b/tests/sptrdiff00.at
|
||||
@@ -0,0 +1,55 @@
|
||||
+# Process this file with autom4te to create testsuite. -*- Autotest -*-
|
||||
+#
|
||||
+# Test suite for GNU tar.
|
||||
+# Copyright 2018 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/>.
|
||||
+
|
||||
+# While fixing CVE-2018-20482 (see sptrcreat.at) it has been discovered
|
||||
+# that similar bug exists in file checking code (tar d).
|
||||
+# This test case checks if tar correctly handles a short read condition
|
||||
+# appearing in check_sparse_region.
|
||||
+
|
||||
+AT_SETUP([file truncated in sparse region while comparing])
|
||||
+AT_KEYWORDS([truncate filechange sparse sptr sptrdiff diff])
|
||||
+
|
||||
+# This triggers short read in check_sparse_region.
|
||||
+AT_TAR_CHECK([
|
||||
+genfile --sparse --block-size=1024 --file foo \
|
||||
+ 0 ABCDEFGHIJ 1M ABCDEFGHIJ 10M ABCDEFGHIJ 200M ABCDEFGHIJ
|
||||
+genfile --file baz
|
||||
+echo creating
|
||||
+tar --sparse -vcf bar foo baz
|
||||
+echo comparing
|
||||
+genfile --run --checkpoint 3 --length 200m --truncate foo -- \
|
||||
+ tar --checkpoint=1 \
|
||||
+ --checkpoint-action=echo='Write checkpoint %u' \
|
||||
+ --checkpoint-action=sleep=1 \
|
||||
+ --sparse -vdf bar
|
||||
+],
|
||||
+[1],
|
||||
+[creating
|
||||
+foo
|
||||
+baz
|
||||
+comparing
|
||||
+foo
|
||||
+foo: Size differs
|
||||
+baz
|
||||
+],
|
||||
+[],
|
||||
+[],[],[posix, gnu, oldgnu])
|
||||
+
|
||||
+AT_CLEANUP
|
||||
diff --git a/tests/sptrdiff01.at b/tests/sptrdiff01.at
|
||||
new file mode 100644
|
||||
index 0000000..2da2267
|
||||
--- /dev/null
|
||||
+++ b/tests/sptrdiff01.at
|
||||
@@ -0,0 +1,55 @@
|
||||
+# Process this file with autom4te to create testsuite. -*- Autotest -*-
|
||||
+#
|
||||
+# Test suite for GNU tar.
|
||||
+# Copyright 2018 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/>.
|
||||
+
|
||||
+# While fixing CVE-2018-20482 (see sptrcreat.at) it has been discovered
|
||||
+# that similar bug exists in file checking code (tar d).
|
||||
+# This test case checks if tar correctly handles a short read condition
|
||||
+# appearing in check_data_region.
|
||||
+
|
||||
+AT_SETUP([file truncated in data region while comparing])
|
||||
+AT_KEYWORDS([truncate filechange sparse sptr sptrdiff diff])
|
||||
+
|
||||
+# This triggers short read in check_data_region.
|
||||
+AT_TAR_CHECK([
|
||||
+genfile --sparse --block-size=1024 --file foo \
|
||||
+ 0 ABCDEFGHIJ 1M ABCDEFGHIJ 10M ABCDEFGHIJ 200M ABCDEFGHIJ
|
||||
+genfile --file baz
|
||||
+echo creating
|
||||
+tar --sparse -vcf bar foo baz
|
||||
+echo comparing
|
||||
+genfile --run --checkpoint 5 --length 221278210 --truncate foo -- \
|
||||
+ tar --checkpoint=1 \
|
||||
+ --checkpoint-action=echo='Write checkpoint %u' \
|
||||
+ --checkpoint-action=sleep=1 \
|
||||
+ --sparse -vdf bar
|
||||
+],
|
||||
+[1],
|
||||
+[creating
|
||||
+foo
|
||||
+baz
|
||||
+comparing
|
||||
+foo
|
||||
+foo: Size differs
|
||||
+baz
|
||||
+],
|
||||
+[],
|
||||
+[],[],[posix, gnu, oldgnu])
|
||||
+
|
||||
+AT_CLEANUP
|
||||
diff --git a/tests/testsuite.at b/tests/testsuite.at
|
||||
index 2a83757..23386f7 100644
|
||||
--- a/tests/testsuite.at
|
||||
+++ b/tests/testsuite.at
|
||||
@@ -1,7 +1,7 @@
|
||||
# Process this file with autom4te to create testsuite. -*- Autotest -*-
|
||||
|
||||
# Test suite for GNU tar.
|
||||
-# Copyright 2004-2008, 2010-2017 Free Software Foundation, Inc.
|
||||
+# Copyright 2004-2008, 2010-2018 Free Software Foundation, Inc.
|
||||
|
||||
# This file is part of GNU tar.
|
||||
|
||||
@@ -405,6 +405,9 @@ m4_include([sparsemv.at])
|
||||
m4_include([spmvp00.at])
|
||||
m4_include([spmvp01.at])
|
||||
m4_include([spmvp10.at])
|
||||
+m4_include([sptrcreat.at])
|
||||
+m4_include([sptrdiff00.at])
|
||||
+m4_include([sptrdiff01.at])
|
||||
|
||||
AT_BANNER([Updates])
|
||||
m4_include([update.at])
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -1,111 +0,0 @@
|
||||
From c7c59b57faa7bd60063f38d3517a8ad50fe1c430 Mon Sep 17 00:00:00 2001
|
||||
From: Sergey Poznyakoff <gray@gnu.org>
|
||||
Date: Thu, 20 Dec 2018 20:30:58 +0200
|
||||
Subject: [PATCH 33/58] Fix buffer overflow
|
||||
|
||||
Bug reported in
|
||||
http://lists.gnu.org/archive/html/bug-tar/2018-12/msg00011.html
|
||||
|
||||
* src/xheader.c (xheader_format_name): fix length calculation
|
||||
---
|
||||
src/xheader.c | 70 ++++++++++++++++++++++++++++-----------------------
|
||||
1 file changed, 39 insertions(+), 31 deletions(-)
|
||||
|
||||
diff --git a/src/xheader.c b/src/xheader.c
|
||||
index 6d97131..980f050 100644
|
||||
--- a/src/xheader.c
|
||||
+++ b/src/xheader.c
|
||||
@@ -255,7 +255,7 @@ char *
|
||||
xheader_format_name (struct tar_stat_info *st, const char *fmt, size_t n)
|
||||
{
|
||||
char *buf;
|
||||
- size_t len = strlen (fmt);
|
||||
+ size_t len;
|
||||
char *q;
|
||||
const char *p;
|
||||
char *dirp = NULL;
|
||||
@@ -266,43 +266,51 @@ xheader_format_name (struct tar_stat_info *st, const char *fmt, size_t n)
|
||||
char nbuf[UINTMAX_STRSIZE_BOUND];
|
||||
char const *nptr = NULL;
|
||||
|
||||
- for (p = fmt; *p && (p = strchr (p, '%')); )
|
||||
+ len = 0;
|
||||
+ for (p = fmt; *p; p++)
|
||||
{
|
||||
- switch (p[1])
|
||||
+ if (*p == '%' && p[1])
|
||||
{
|
||||
- case '%':
|
||||
- len--;
|
||||
- break;
|
||||
-
|
||||
- case 'd':
|
||||
- if (st)
|
||||
+ switch (*++p)
|
||||
{
|
||||
- if (!dirp)
|
||||
- dirp = dir_name (st->orig_file_name);
|
||||
- dir = safer_name_suffix (dirp, false, absolute_names_option);
|
||||
- len += strlen (dir) - 2;
|
||||
- }
|
||||
- break;
|
||||
+ case '%':
|
||||
+ len++;
|
||||
+ break;
|
||||
|
||||
- case 'f':
|
||||
- if (st)
|
||||
- {
|
||||
- base = last_component (st->orig_file_name);
|
||||
- len += strlen (base) - 2;
|
||||
- }
|
||||
- break;
|
||||
+ case 'd':
|
||||
+ if (st)
|
||||
+ {
|
||||
+ if (!dirp)
|
||||
+ dirp = dir_name (st->orig_file_name);
|
||||
+ dir = safer_name_suffix (dirp, false, absolute_names_option);
|
||||
+ len += strlen (dir);
|
||||
+ }
|
||||
+ break;
|
||||
|
||||
- case 'p':
|
||||
- pptr = umaxtostr (getpid (), pidbuf);
|
||||
- len += pidbuf + sizeof pidbuf - 1 - pptr - 2;
|
||||
- break;
|
||||
+ case 'f':
|
||||
+ if (st)
|
||||
+ {
|
||||
+ base = last_component (st->orig_file_name);
|
||||
+ len += strlen (base);
|
||||
+ }
|
||||
+ break;
|
||||
|
||||
- case 'n':
|
||||
- nptr = umaxtostr (n, nbuf);
|
||||
- len += nbuf + sizeof nbuf - 1 - nptr - 2;
|
||||
- break;
|
||||
+ case 'p':
|
||||
+ pptr = umaxtostr (getpid (), pidbuf);
|
||||
+ len += pidbuf + sizeof pidbuf - 1 - pptr;
|
||||
+ break;
|
||||
+
|
||||
+ case 'n':
|
||||
+ nptr = umaxtostr (n, nbuf);
|
||||
+ len += nbuf + sizeof nbuf - 1 - nptr;
|
||||
+ break;
|
||||
+
|
||||
+ default:
|
||||
+ len += 2;
|
||||
+ }
|
||||
}
|
||||
- p++;
|
||||
+ else
|
||||
+ len++;
|
||||
}
|
||||
|
||||
buf = xmalloc (len + 1);
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -1,28 +0,0 @@
|
||||
From bd1b0fc97c95686175057a203c7a1cf7b79cb19b Mon Sep 17 00:00:00 2001
|
||||
From: Sergey Poznyakoff <gray@gnu.org>
|
||||
Date: Tue, 15 Jan 2019 15:21:03 +0200
|
||||
Subject: [PATCH 55/58] Fix build on AIX
|
||||
|
||||
* src/unlink.c (flush_deferred_unlinks): Avoid possible duplicate case
|
||||
(if ENOTEMPTY==EEXIST)
|
||||
---
|
||||
src/unlink.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/src/unlink.c b/src/unlink.c
|
||||
index 8f3a8a4..5a72f70 100644
|
||||
--- a/src/unlink.c
|
||||
+++ b/src/unlink.c
|
||||
@@ -127,7 +127,9 @@ flush_deferred_unlinks (bool force)
|
||||
case EEXIST:
|
||||
/* OpenSolaris >=10 sets EEXIST instead of ENOTEMPTY
|
||||
if trying to remove a non-empty directory */
|
||||
+#if defined ENOTEMPTY && ENOTEMPTY != EEXIST
|
||||
case ENOTEMPTY:
|
||||
+#endif
|
||||
/* Keep the record in list, in the hope we'll
|
||||
be able to remove it later */
|
||||
prev = p;
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
From 2f5a57be4bcb4b6e641457ef0fc99bdbe84828ba Mon Sep 17 00:00:00 2001
|
||||
From: Sergey Poznyakoff <gray@gnu.org>
|
||||
Date: Mon, 14 Jan 2019 14:46:43 +0200
|
||||
Subject: [PATCH 50/58] Fix compilation without iconv.
|
||||
|
||||
---
|
||||
src/utf8.c | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/utf8.c b/src/utf8.c
|
||||
index 91476aa..53a1ab2 100644
|
||||
--- a/src/utf8.c
|
||||
+++ b/src/utf8.c
|
||||
@@ -35,11 +35,14 @@
|
||||
# define iconv_open(tocode, fromcode) ((iconv_t) -1)
|
||||
|
||||
# undef iconv
|
||||
-# define iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft) ((size_t) 0)
|
||||
+# define iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft) (errno = ENOSYS, (size_t) -1)
|
||||
|
||||
# undef iconv_close
|
||||
# define iconv_close(cd) 0
|
||||
|
||||
+# undef iconv_t
|
||||
+# define iconv_t int
|
||||
+
|
||||
#endif
|
||||
|
||||
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -1,44 +0,0 @@
|
||||
From 110e3bd7a6e63e0c5c734d97a0a44ed5c1b6de7c Mon Sep 17 00:00:00 2001
|
||||
From: Sergey Poznyakoff <gray@gnu.org>
|
||||
Date: Tue, 31 Jul 2018 15:57:11 +0300
|
||||
Subject: [PATCH 22/58] Fix double-free introduced by 577dc345
|
||||
|
||||
* src/utf8.c (utf8_convert): Don't store freed value in *output
|
||||
---
|
||||
src/utf8.c | 7 ++++---
|
||||
1 file changed, 4 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/utf8.c b/src/utf8.c
|
||||
index 168d636..abf26bc 100644
|
||||
--- a/src/utf8.c
|
||||
+++ b/src/utf8.c
|
||||
@@ -65,7 +65,7 @@ bool
|
||||
utf8_convert (bool to_utf, char const *input, char **output)
|
||||
{
|
||||
char ICONV_CONST *ib;
|
||||
- char *ob;
|
||||
+ char *ob, *ret;
|
||||
size_t inlen;
|
||||
size_t outlen;
|
||||
iconv_t cd = utf8_init (to_utf);
|
||||
@@ -80,14 +80,15 @@ utf8_convert (bool to_utf, char const *input, char **output)
|
||||
|
||||
inlen = strlen (input) + 1;
|
||||
outlen = inlen * MB_LEN_MAX + 1;
|
||||
- ob = *output = xmalloc (outlen);
|
||||
+ ob = ret = xmalloc (outlen);
|
||||
ib = (char ICONV_CONST *) input;
|
||||
if (iconv (cd, &ib, &inlen, &ob, &outlen) == -1)
|
||||
{
|
||||
- free (*output);
|
||||
+ free (ret);
|
||||
return false;
|
||||
}
|
||||
*ob = 0;
|
||||
+ *output = ret;
|
||||
return true;
|
||||
}
|
||||
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -1,84 +0,0 @@
|
||||
From 916fe62ae9b91a5d71cfa752f7cad89a558d7672 Mon Sep 17 00:00:00 2001
|
||||
From: Sergey Poznyakoff <gray@gnu.org>
|
||||
Date: Fri, 21 Dec 2018 07:59:02 +0200
|
||||
Subject: [PATCH 35/58] Fix error handling when reading incremental snapshots
|
||||
|
||||
Bug reported in
|
||||
http://lists.gnu.org/archive/html/bug-tar/2018-12/msg00008.html
|
||||
|
||||
* incremen.c (read_incr_db_01): Don't try to continue after errors.
|
||||
---
|
||||
src/incremen.c | 30 +++++++++++++++---------------
|
||||
1 file changed, 15 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/src/incremen.c b/src/incremen.c
|
||||
index 7c26eb8..8335a0c 100644
|
||||
--- a/src/incremen.c
|
||||
+++ b/src/incremen.c
|
||||
@@ -998,10 +998,10 @@ read_incr_db_01 (int version, const char *initbuf)
|
||||
newer_mtime_option = decode_timespec (buf, &ebuf, false);
|
||||
|
||||
if (! valid_timespec (newer_mtime_option))
|
||||
- ERROR ((0, errno, "%s:%ld: %s",
|
||||
- quotearg_colon (listed_incremental_option),
|
||||
- lineno,
|
||||
- _("Invalid time stamp")));
|
||||
+ FATAL_ERROR ((0, errno, "%s:%ld: %s",
|
||||
+ quotearg_colon (listed_incremental_option),
|
||||
+ lineno,
|
||||
+ _("Invalid time stamp")));
|
||||
else
|
||||
{
|
||||
if (version == 1 && *ebuf)
|
||||
@@ -1043,9 +1043,9 @@ read_incr_db_01 (int version, const char *initbuf)
|
||||
mtime = decode_timespec (strp, &ebuf, false);
|
||||
strp = ebuf;
|
||||
if (!valid_timespec (mtime) || *strp != ' ')
|
||||
- ERROR ((0, errno, "%s:%ld: %s",
|
||||
- quotearg_colon (listed_incremental_option), lineno,
|
||||
- _("Invalid modification time")));
|
||||
+ FATAL_ERROR ((0, errno, "%s:%ld: %s",
|
||||
+ quotearg_colon (listed_incremental_option), lineno,
|
||||
+ _("Invalid modification time")));
|
||||
|
||||
errno = 0;
|
||||
u = strtoumax (strp, &ebuf, 10);
|
||||
@@ -1053,9 +1053,9 @@ read_incr_db_01 (int version, const char *initbuf)
|
||||
errno = ERANGE;
|
||||
if (errno || strp == ebuf || *ebuf != ' ')
|
||||
{
|
||||
- ERROR ((0, errno, "%s:%ld: %s",
|
||||
- quotearg_colon (listed_incremental_option), lineno,
|
||||
- _("Invalid modification time (nanoseconds)")));
|
||||
+ FATAL_ERROR ((0, errno, "%s:%ld: %s",
|
||||
+ quotearg_colon (listed_incremental_option), lineno,
|
||||
+ _("Invalid modification time (nanoseconds)")));
|
||||
mtime.tv_nsec = -1;
|
||||
}
|
||||
else
|
||||
@@ -1069,17 +1069,17 @@ read_incr_db_01 (int version, const char *initbuf)
|
||||
TYPE_MINIMUM (dev_t), TYPE_MAXIMUM (dev_t));
|
||||
strp = ebuf;
|
||||
if (errno || *strp != ' ')
|
||||
- ERROR ((0, errno, "%s:%ld: %s",
|
||||
+ FATAL_ERROR ((0, errno, "%s:%ld: %s",
|
||||
quotearg_colon (listed_incremental_option), lineno,
|
||||
- _("Invalid device number")));
|
||||
+ _("Invalid device number")));
|
||||
|
||||
ino = strtosysint (strp, &ebuf,
|
||||
TYPE_MINIMUM (ino_t), TYPE_MAXIMUM (ino_t));
|
||||
strp = ebuf;
|
||||
if (errno || *strp != ' ')
|
||||
- ERROR ((0, errno, "%s:%ld: %s",
|
||||
- quotearg_colon (listed_incremental_option), lineno,
|
||||
- _("Invalid inode number")));
|
||||
+ FATAL_ERROR ((0, errno, "%s:%ld: %s",
|
||||
+ quotearg_colon (listed_incremental_option), lineno,
|
||||
+ _("Invalid inode number")));
|
||||
|
||||
strp++;
|
||||
unquote_string (strp);
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -1,39 +0,0 @@
|
||||
From 3da8c2850d6589b9fa387ab2a2c87355d1224b1e Mon Sep 17 00:00:00 2001
|
||||
From: Sergey Poznyakoff <gray@gnu.org>
|
||||
Date: Mon, 14 Jan 2019 13:59:39 +0200
|
||||
Subject: [PATCH 49/58] Fix iconv usage.
|
||||
|
||||
Patch by Christian Weisgerber.
|
||||
|
||||
* src/utf8.c (utf8_convert): non-zero return from iconv means failure.
|
||||
---
|
||||
src/utf8.c | 13 ++++++++++++-
|
||||
1 file changed, 12 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/utf8.c b/src/utf8.c
|
||||
index 95a016d..91476aa 100644
|
||||
--- a/src/utf8.c
|
||||
+++ b/src/utf8.c
|
||||
@@ -81,7 +81,18 @@ utf8_convert (bool to_utf, char const *input, char **output)
|
||||
outlen = inlen * MB_LEN_MAX + 1;
|
||||
ob = ret = xmalloc (outlen);
|
||||
ib = (char ICONV_CONST *) input;
|
||||
- if (iconv (cd, &ib, &inlen, &ob, &outlen) == -1)
|
||||
+ /* According to POSIX, "if iconv() encounters a character in the input
|
||||
+ buffer that is valid, but for which an identical character does not
|
||||
+ exist in the target codeset, iconv() shall perform an
|
||||
+ implementation-defined conversion on this character." It will "update
|
||||
+ the variables pointed to by the arguments to reflect the extent of the
|
||||
+ conversion and return the number of non-identical conversions performed".
|
||||
+ On error, it returns -1.
|
||||
+ In other words, non-zero return always indicates failure, either because
|
||||
+ the input was not fully converted, or because it was converted in a
|
||||
+ non-reversible way.
|
||||
+ */
|
||||
+ if (iconv (cd, &ib, &inlen, &ob, &outlen) != 0)
|
||||
{
|
||||
free (ret);
|
||||
return false;
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
From eae48289c0848c5812644f20dbb1b39fb117a8f6 Mon Sep 17 00:00:00 2001
|
||||
From: Sergey Poznyakoff <gray@gnu.org>
|
||||
Date: Thu, 20 Dec 2018 17:53:40 +0200
|
||||
Subject: [PATCH 32/58] Fix improper memory access
|
||||
|
||||
Bug reported in
|
||||
http://lists.gnu.org/archive/html/bug-tar/2018-12/msg00009.html
|
||||
|
||||
* src/transform.c (parse_transform_expr): Check if re is not empty
|
||||
before accessing its last byte.
|
||||
---
|
||||
src/transform.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/transform.c b/src/transform.c
|
||||
index 6ef0da6..bbf2033 100644
|
||||
--- a/src/transform.c
|
||||
+++ b/src/transform.c
|
||||
@@ -273,7 +273,7 @@ parse_transform_expr (const char *expr)
|
||||
USAGE_ERROR ((0, 0, _("Invalid transform expression: %s"), errbuf));
|
||||
}
|
||||
|
||||
- if (str[0] == '^' || str[strlen (str) - 1] == '$')
|
||||
+ if (str[0] == '^' || (i > 2 && str[i - 3] == '$'))
|
||||
tf->transform_type = transform_first;
|
||||
|
||||
free (str);
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
From cb07844454d8cc9fb21f53ace75975f91185a120 Mon Sep 17 00:00:00 2001
|
||||
From: Sergey Poznyakoff <gray@gnu.org>
|
||||
Date: Mon, 14 Jan 2019 15:22:09 +0200
|
||||
Subject: [PATCH] Fix possible NULL dereference (savannah bug #55369)
|
||||
|
||||
* src/sparse.c (pax_decode_header): Check return from find_next_block.
|
||||
---
|
||||
src/sparse.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/src/sparse.c b/src/sparse.c
|
||||
index 55c874f..6ec069d 100644
|
||||
--- a/src/sparse.c
|
||||
+++ b/src/sparse.c
|
||||
@@ -1247,6 +1247,8 @@ pax_decode_header (struct tar_sparse_file *file)
|
||||
set_next_block_after (b); \
|
||||
file->dumped_size += BLOCKSIZE; \
|
||||
b = find_next_block (); \
|
||||
+ if (!b) \
|
||||
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); \
|
||||
src = b->buffer; \
|
||||
endp = b->buffer + BLOCKSIZE; \
|
||||
} \
|
||||
@@ -1259,6 +1261,8 @@ pax_decode_header (struct tar_sparse_file *file)
|
||||
set_next_block_after (current_header);
|
||||
file->dumped_size += BLOCKSIZE;
|
||||
blk = find_next_block ();
|
||||
+ if (!blk)
|
||||
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
|
||||
p = blk->buffer;
|
||||
COPY_BUF (blk,nbuf,p);
|
||||
if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t)))
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,130 +0,0 @@
|
||||
From 983a82a3767da04cb3ca15eefe2e4b21154c335f Mon Sep 17 00:00:00 2001
|
||||
From: Sergey Poznyakoff <gray@gnu.org>
|
||||
Date: Fri, 21 Dec 2018 13:24:29 +0200
|
||||
Subject: [PATCH 36/58] Fix semantics of -K used together with explicit member
|
||||
names.
|
||||
|
||||
This also fixes the bug reported in
|
||||
http://lists.gnu.org/archive/html/bug-tar/2018-12/msg00012.html
|
||||
|
||||
* src/common.h (starting_file_option): Describe the variable.
|
||||
* src/names.c (add_starting_file): New function.
|
||||
(name_match): Ignore everything before the member indicated by the
|
||||
--starting-file option
|
||||
* src/tar.c: Use add_starting_file to handle the -K option.
|
||||
---
|
||||
NEWS | 12 +++++++++++-
|
||||
src/common.h | 5 +++++
|
||||
src/names.c | 45 ++++++++++++++++++++++++++++++++++++++-------
|
||||
src/tar.c | 3 +--
|
||||
4 files changed, 55 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/src/common.h b/src/common.h
|
||||
index 2877975..32e6f8b 100644
|
||||
--- a/src/common.h
|
||||
+++ b/src/common.h
|
||||
@@ -302,6 +302,10 @@ enum hole_detection_method
|
||||
|
||||
GLOBAL enum hole_detection_method hole_detection;
|
||||
|
||||
+/* The first entry in names.c:namelist specifies the member name to
|
||||
+ start extracting from. Set by add_starting_file() upon seeing the
|
||||
+ -K option.
|
||||
+*/
|
||||
GLOBAL bool starting_file_option;
|
||||
|
||||
/* Specified maximum byte length of each tape volume (multiple of 1024). */
|
||||
@@ -752,6 +756,7 @@ const char *name_next (int change_dirs);
|
||||
void name_gather (void);
|
||||
struct name *addname (char const *string, int change_dir,
|
||||
bool cmdline, struct name *parent);
|
||||
+void add_starting_file (char const *file_name);
|
||||
void remname (struct name *name);
|
||||
bool name_match (const char *name);
|
||||
void names_notfound (void);
|
||||
diff --git a/src/names.c b/src/names.c
|
||||
index f4dc978..d3728d8 100644
|
||||
--- a/src/names.c
|
||||
+++ b/src/names.c
|
||||
@@ -1227,6 +1227,34 @@ addname (char const *string, int change_dir, bool cmdline, struct name *parent)
|
||||
return name;
|
||||
}
|
||||
|
||||
+void
|
||||
+add_starting_file (char const *file_name)
|
||||
+{
|
||||
+ struct name *name = make_name (file_name);
|
||||
+
|
||||
+ if (starting_file_option)
|
||||
+ {
|
||||
+ struct name *head = namelist;
|
||||
+ remname (head);
|
||||
+ free_name (head);
|
||||
+ }
|
||||
+
|
||||
+ name->prev = NULL;
|
||||
+ name->next = namelist;
|
||||
+ namelist = name;
|
||||
+ if (!nametail)
|
||||
+ nametail = namelist;
|
||||
+
|
||||
+ name->found_count = 0;
|
||||
+ name->matching_flags = INCLUDE_OPTIONS;
|
||||
+ name->change_dir = 0;
|
||||
+ name->directory = NULL;
|
||||
+ name->parent = NULL;
|
||||
+ name->cmdline = true;
|
||||
+
|
||||
+ starting_file_option = true;
|
||||
+}
|
||||
+
|
||||
/* Find a match for FILE_NAME (whose string length is LENGTH) in the name
|
||||
list. */
|
||||
static struct name *
|
||||
@@ -1283,19 +1311,22 @@ name_match (const char *file_name)
|
||||
}
|
||||
|
||||
cursor = namelist_match (file_name, length);
|
||||
+ if (starting_file_option)
|
||||
+ {
|
||||
+ /* If starting_file_option is set, the head of the list is the name
|
||||
+ of the member to start extraction from. Skip the match unless it
|
||||
+ is head. */
|
||||
+ if (cursor == namelist)
|
||||
+ starting_file_option = false;
|
||||
+ else
|
||||
+ cursor = NULL;
|
||||
+ }
|
||||
if (cursor)
|
||||
{
|
||||
if (!(ISSLASH (file_name[cursor->length]) && recursion_option)
|
||||
|| cursor->found_count == 0)
|
||||
cursor->found_count++; /* remember it matched */
|
||||
- if (starting_file_option)
|
||||
- {
|
||||
- free (namelist);
|
||||
- namelist = NULL;
|
||||
- nametail = NULL;
|
||||
- }
|
||||
chdir_do (cursor->change_dir);
|
||||
-
|
||||
/* We got a match. */
|
||||
return ISFOUND (cursor);
|
||||
}
|
||||
diff --git a/src/tar.c b/src/tar.c
|
||||
index 1993887..9919e87 100644
|
||||
--- a/src/tar.c
|
||||
+++ b/src/tar.c
|
||||
@@ -1443,8 +1443,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
|
||||
|
||||
case 'K':
|
||||
optloc_save (OC_STARTING_FILE, args->loc);
|
||||
- starting_file_option = true;
|
||||
- addname (arg, 0, true, NULL);
|
||||
+ add_starting_file (arg);
|
||||
break;
|
||||
|
||||
case ONE_FILE_SYSTEM_OPTION:
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
From 99d415e1902c2309a4a3da41b2f08e5719771336 Mon Sep 17 00:00:00 2001
|
||||
From: Sergey Poznyakoff <gray@gnu.org>
|
||||
Date: Fri, 21 Dec 2018 07:32:47 +0200
|
||||
Subject: [PATCH 34/58] Reject pax options starting with equals sign
|
||||
|
||||
Bug reported in
|
||||
http://lists.gnu.org/archive/html/bug-tar/2018-12/msg00010.html
|
||||
|
||||
* xheader.c (xheader_set_keyword_equal): Bail out if the keyword starts
|
||||
with =
|
||||
---
|
||||
src/xheader.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/src/xheader.c b/src/xheader.c
|
||||
index 980f050..e938502 100644
|
||||
--- a/src/xheader.c
|
||||
+++ b/src/xheader.c
|
||||
@@ -185,6 +185,9 @@ xheader_set_keyword_equal (char *kw, char *eq)
|
||||
bool global = true;
|
||||
char *p = eq;
|
||||
|
||||
+ if (eq == kw)
|
||||
+ USAGE_ERROR ((0, 0, _("Malformed pax option: %s"), quote (kw)));
|
||||
+
|
||||
if (eq[-1] == ':')
|
||||
{
|
||||
p--;
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
From 85c005ee1345c342f707f3c55317daf6cb050603 Mon Sep 17 00:00:00 2001
|
||||
From: Sergey Poznyakoff <gray@gnu.org.ua>
|
||||
Date: Thu, 10 Jan 2019 18:18:49 +0200
|
||||
Subject: [PATCH 44/58] Remove erroneous abort() call
|
||||
|
||||
The call was introduced by commit ccef8581. It caused tar to abort
|
||||
on perfectly normal operations, like untarring archives containing
|
||||
./ with the -U option,
|
||||
|
||||
See http://lists.gnu.org/archive/html/bug-tar/2019-01/msg00019.html
|
||||
for details.
|
||||
|
||||
* src/extract.c (maybe_recoverable): Remove misplaced call to abort().
|
||||
---
|
||||
src/extract.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/extract.c b/src/extract.c
|
||||
index 090b866..8276f8f 100644
|
||||
--- a/src/extract.c
|
||||
+++ b/src/extract.c
|
||||
@@ -787,7 +787,7 @@ maybe_recoverable (char *file_name, bool regular, bool *interdir_made)
|
||||
case UNLINK_FIRST_OLD_FILES:
|
||||
break;
|
||||
}
|
||||
- abort (); /* notreached */
|
||||
+ FALLTHROUGH;
|
||||
|
||||
case ENOENT:
|
||||
/* Attempt creating missing intermediate directories. */
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
From c1b569d9d61f129d2eefd1e87e6ea6cd96810788 Mon Sep 17 00:00:00 2001
|
||||
From: Pavel Raiskup <praiskup@redhat.com>
|
||||
Date: Tue, 31 Jul 2018 12:13:48 +0300
|
||||
Subject: [PATCH 21/58] Report race on systems without O_DIRECTORY
|
||||
|
||||
* src/names.c (collect_and_sort_names): Report ENOTDIR after
|
||||
successful fstat() but !S_ISDIR.
|
||||
---
|
||||
src/names.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/src/names.c b/src/names.c
|
||||
index f6ad9fe..f4dc978 100644
|
||||
--- a/src/names.c
|
||||
+++ b/src/names.c
|
||||
@@ -1767,6 +1767,11 @@ collect_and_sort_names (void)
|
||||
name->found_count++;
|
||||
add_hierarchy_to_namelist (&st, name);
|
||||
}
|
||||
+ else
|
||||
+ {
|
||||
+ errno = ENOTDIR;
|
||||
+ open_diag (name->name);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -1,45 +0,0 @@
|
||||
From 2d00d8b32190ca7135673999b175850019746042 Mon Sep 17 00:00:00 2001
|
||||
From: Sergey Poznyakoff <gray@gnu.org>
|
||||
Date: Sat, 7 Apr 2018 10:33:27 +0300
|
||||
Subject: [PATCH 10/58] Rewrite struct tm formatting
|
||||
|
||||
* src/list.c (tartime): Use strftime instead of manually formatting
|
||||
fields of the struct tm. This should also suppress some gcc warnings.
|
||||
---
|
||||
src/list.c | 10 +++-------
|
||||
1 file changed, 3 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/list.c b/src/list.c
|
||||
index 14388a5..2cc5d40 100644
|
||||
--- a/src/list.c
|
||||
+++ b/src/list.c
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <system.h>
|
||||
#include <inttostr.h>
|
||||
#include <quotearg.h>
|
||||
-
|
||||
+#include <time.h>
|
||||
#include "common.h"
|
||||
|
||||
union block *current_header; /* points to current archive header */
|
||||
@@ -1049,15 +1049,11 @@ tartime (struct timespec t, bool full_time)
|
||||
{
|
||||
if (full_time)
|
||||
{
|
||||
- sprintf (buffer, "%04ld-%02d-%02d %02d:%02d:%02d",
|
||||
- tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday,
|
||||
- tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
+ strftime (buffer, sizeof buffer, "%Y-%m-%d %H:%M:%S", tm);
|
||||
code_ns_fraction (ns, buffer + strlen (buffer));
|
||||
}
|
||||
else
|
||||
- sprintf (buffer, "%04ld-%02d-%02d %02d:%02d",
|
||||
- tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday,
|
||||
- tm->tm_hour, tm->tm_min);
|
||||
+ strftime (buffer, sizeof buffer, "%Y-%m-%d %H:%M", tm);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -1,94 +0,0 @@
|
||||
From 9d1993f651d72f78b2afe416c72b1aeb0c1215ab Mon Sep 17 00:00:00 2001
|
||||
From: Sergey Poznyakoff <gray@gnu.org>
|
||||
Date: Fri, 28 Dec 2018 17:49:08 +0200
|
||||
Subject: [PATCH 41/58] Work over a bug in gnulib error()
|
||||
|
||||
The error() function from glibc correctly prefixes each message it
|
||||
prints with program_name as set by set_program_name. However, its
|
||||
replacement from gnulib, which is linked in on systems where this
|
||||
function is not available, prints the name returned by getprogname()
|
||||
instead. Due to this messages output by tar subprocess (which sets its
|
||||
program name to 'tar (child)') become indiscernible from those printed
|
||||
by the main process. In particular, this breaks the remfiles01.at and
|
||||
remfiles02.at test cases.
|
||||
|
||||
* configure.ac: Define ENABLE_ERROR_PRINT_PROGNAME if using
|
||||
gnulib error().
|
||||
* src/tar.c [ENABLE_ERROR_PRINT_PROGNAME] (tar_print_progname): New function.
|
||||
(main) [ENABLE_ERROR_PRINT_PROGNAME]: Set error_print_progname.
|
||||
---
|
||||
configure.ac | 12 ++++++++++++
|
||||
src/tar.c | 27 +++++++++++++++++++++++++--
|
||||
2 files changed, 37 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 66ed8ca..8e4207b 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -102,6 +102,18 @@ gt_TYPE_SSIZE_T
|
||||
|
||||
# gnulib modules
|
||||
gl_INIT
|
||||
+
|
||||
+if test $ac_cv_lib_error_at_line = no; then
|
||||
+ # This means that the error() function is not present in libc, so
|
||||
+ # the one from gnulib will be used instead. This function precedes
|
||||
+ # error messages it prints with the program name as returned by getprogname()
|
||||
+ # call, instead of using the name set by set_program_name.
|
||||
+ # Install workaround.
|
||||
+ AC_DEFINE([ENABLE_ERROR_PRINT_PROGNAME],[1],
|
||||
+ [Enable the use of error_print_progname to print program name with error messages.
|
||||
+ See comment to function tar_print_progname in src/tar.c])
|
||||
+fi
|
||||
+
|
||||
# paxutils modules
|
||||
tar_PAXUTILS
|
||||
|
||||
diff --git a/src/tar.c b/src/tar.c
|
||||
index 9c939f3..721d777 100644
|
||||
--- a/src/tar.c
|
||||
+++ b/src/tar.c
|
||||
@@ -2666,7 +2666,28 @@ decode_options (int argc, char **argv)
|
||||
|
||||
report_textual_dates (&args);
|
||||
}
|
||||
-
|
||||
+
|
||||
+#ifdef ENABLE_ERROR_PRINT_PROGNAME
|
||||
+/* The error() function from glibc correctly prefixes each message it
|
||||
+ prints with program_name as set by set_program_name. However, its
|
||||
+ replacement from gnulib, which is linked in on systems where this
|
||||
+ function is not available, prints the name returned by getprogname()
|
||||
+ instead. Due to this messages output by tar subprocess (which sets its
|
||||
+ program name to 'tar (child)') become indiscernible from those printed
|
||||
+ by the main process. In particular, this breaks the remfiles01.at and
|
||||
+ remfiles02.at test cases.
|
||||
+
|
||||
+ To avoid this, on such systems the following helper function is used
|
||||
+ to print proper program name. Its address is assigned to the
|
||||
+ error_print_progname variable, which error() then uses instead of
|
||||
+ printing getprogname() result.
|
||||
+ */
|
||||
+static void
|
||||
+tar_print_progname (void)
|
||||
+{
|
||||
+ fprintf (stderr, "%s: ", program_name);
|
||||
+}
|
||||
+#endif
|
||||
|
||||
/* Tar proper. */
|
||||
|
||||
@@ -2676,7 +2697,9 @@ main (int argc, char **argv)
|
||||
{
|
||||
set_start_time ();
|
||||
set_program_name (argv[0]);
|
||||
-
|
||||
+#ifdef ENABLE_ERROR_PRINT_PROGNAME
|
||||
+ error_print_progname = tar_print_progname;
|
||||
+#endif
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -1,47 +0,0 @@
|
||||
From 0a0242582f134c9994bbad77a57f64d388cf9e19 Mon Sep 17 00:00:00 2001
|
||||
From: Jim Meyering <meyering@fb.com>
|
||||
Date: Sun, 18 Mar 2018 21:32:19 -0700
|
||||
Subject: [PATCH 13/58] maint: avoid -Wstringop-truncation warnings from
|
||||
upcoming GCC8
|
||||
|
||||
* src/create.c (start_private_header, start_header): Convert
|
||||
trivial uses of strncpy to memcpy, to avoid warnings like this:
|
||||
In function 'strncpy',
|
||||
inlined from 'start_private_header' at create.c:522:3:
|
||||
/usr/include/bits/string_fortified.h:106:10: warning: \
|
||||
'__builtin_strncpy' output truncated before terminating nul \
|
||||
copying 2 bytes from a string of the same length \
|
||||
[-Wstringop-truncation]
|
||||
---
|
||||
src/create.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/create.c b/src/create.c
|
||||
index 35bcf5b..7737c52 100644
|
||||
--- a/src/create.c
|
||||
+++ b/src/create.c
|
||||
@@ -518,8 +518,8 @@ start_private_header (const char *name, size_t size, time_t t)
|
||||
MODE_TO_CHARS (S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, header->header.mode);
|
||||
UID_TO_CHARS (0, header->header.uid);
|
||||
GID_TO_CHARS (0, header->header.gid);
|
||||
- strncpy (header->header.magic, TMAGIC, TMAGLEN);
|
||||
- strncpy (header->header.version, TVERSION, TVERSLEN);
|
||||
+ memcpy (header->header.magic, TMAGIC, TMAGLEN);
|
||||
+ memcpy (header->header.version, TVERSION, TVERSLEN);
|
||||
return header;
|
||||
}
|
||||
|
||||
@@ -917,8 +917,8 @@ start_header (struct tar_stat_info *st)
|
||||
|
||||
case POSIX_FORMAT:
|
||||
case USTAR_FORMAT:
|
||||
- strncpy (header->header.magic, TMAGIC, TMAGLEN);
|
||||
- strncpy (header->header.version, TVERSION, TVERSLEN);
|
||||
+ memcpy (header->header.magic, TMAGIC, TMAGLEN);
|
||||
+ memcpy (header->header.version, TVERSION, TVERSLEN);
|
||||
break;
|
||||
|
||||
default:
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -1,50 +0,0 @@
|
||||
From 2baa531ce53d5876d34f941a97b5041573da453a Mon Sep 17 00:00:00 2001
|
||||
From: Jim Meyering <meyering@fb.com>
|
||||
Date: Sun, 18 Mar 2018 21:20:28 -0700
|
||||
Subject: [PATCH 12/58] maint: avoid -Wstringop-truncation warnings upcoming
|
||||
GCC8
|
||||
|
||||
* src/buffer.c (gnu_add_multi_volume_header): Convert a use of
|
||||
strncpy to memcpy, to avoid this warning:
|
||||
In function 'strncpy',
|
||||
inlined from 'gnu_add_multi_volume_header' at buffer.c:1782:3,
|
||||
...
|
||||
/usr/include/bits/string_fortified.h:106:10: error: '__builtin_strncpy'\
|
||||
specified bound 100 equals destination size \
|
||||
[-Werror=stringop-truncation]
|
||||
---
|
||||
src/buffer.c | 14 +++++++++-----
|
||||
1 file changed, 9 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/buffer.c b/src/buffer.c
|
||||
index 063e1be..b710c6a 100644
|
||||
--- a/src/buffer.c
|
||||
+++ b/src/buffer.c
|
||||
@@ -1771,15 +1771,19 @@ gnu_add_multi_volume_header (struct bufmap *map)
|
||||
{
|
||||
int tmp;
|
||||
union block *block = find_next_block ();
|
||||
+ size_t len = strlen (map->file_name);
|
||||
|
||||
- if (strlen (map->file_name) > NAME_FIELD_SIZE)
|
||||
- WARN ((0, 0,
|
||||
- _("%s: file name too long to be stored in a GNU multivolume header, truncated"),
|
||||
- quotearg_colon (map->file_name)));
|
||||
+ if (len > NAME_FIELD_SIZE)
|
||||
+ {
|
||||
+ WARN ((0, 0,
|
||||
+ _("%s: file name too long to be stored in a GNU multivolume header, truncated"),
|
||||
+ quotearg_colon (map->file_name)));
|
||||
+ len = NAME_FIELD_SIZE;
|
||||
+ }
|
||||
|
||||
memset (block, 0, BLOCKSIZE);
|
||||
|
||||
- strncpy (block->header.name, map->file_name, NAME_FIELD_SIZE);
|
||||
+ memcpy (block->header.name, map->file_name, len);
|
||||
block->header.typeflag = GNUTYPE_MULTIVOL;
|
||||
|
||||
OFF_TO_CHARS (map->sizeleft, block->header.size);
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -1,43 +0,0 @@
|
||||
From ccef8581b8673cadd1c084595de4efde956c3c2b Mon Sep 17 00:00:00 2001
|
||||
From: Jim Meyering <meyering@fb.com>
|
||||
Date: Sun, 18 Mar 2018 17:59:25 -0700
|
||||
Subject: [PATCH 11/58] maint: avoid warnings from upcoming GCC8
|
||||
|
||||
* src/transform.c (_single_transform_name_to_obstack): Mark with
|
||||
FALLTHROUGH statement rather than /* FALL THROUGH */ comment.
|
||||
Only the former works with gcc-8.
|
||||
* src/extract.c (maybe_recoverable): Call abort to tell gcc-8 that
|
||||
this code is unreachable.
|
||||
---
|
||||
src/extract.c | 1 +
|
||||
src/transform.c | 2 +-
|
||||
2 files changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/extract.c b/src/extract.c
|
||||
index 395db55..74987bb 100644
|
||||
--- a/src/extract.c
|
||||
+++ b/src/extract.c
|
||||
@@ -788,6 +788,7 @@ maybe_recoverable (char *file_name, bool regular, bool *interdir_made)
|
||||
case UNLINK_FIRST_OLD_FILES:
|
||||
break;
|
||||
}
|
||||
+ abort (); /* notreached */
|
||||
|
||||
case ENOENT:
|
||||
/* Attempt creating missing intermediate directories. */
|
||||
diff --git a/src/transform.c b/src/transform.c
|
||||
index e450dd2..3fae3c0 100644
|
||||
--- a/src/transform.c
|
||||
+++ b/src/transform.c
|
||||
@@ -550,7 +550,7 @@ _single_transform_name_to_obstack (struct transform *tf, char *input)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
- /*FALL THROUGH*/
|
||||
+ FALLTHROUGH;
|
||||
|
||||
case ctl_upcase:
|
||||
case ctl_locase:
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -1,73 +0,0 @@
|
||||
From b531801d6f49d64a126720e6004aae7c800764b2 Mon Sep 17 00:00:00 2001
|
||||
From: Jim Meyering <meyering@fb.com>
|
||||
Date: Sat, 7 Apr 2018 08:41:46 -0700
|
||||
Subject: [PATCH 16/58] --one-top-level: avoid a heap-buffer-overflow
|
||||
|
||||
* NEWS: Mention this.
|
||||
* src/suffix.c (strip_compression_suffix): Fix string comparison guard.
|
||||
Without this change, some ASAN-enabled test runs would fail with the
|
||||
following. Also, strip an additional .tar suffix only if the just-
|
||||
stripped suffix did not match /^\.t/".
|
||||
|
||||
==30815==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020000002ed at pc 0x00000049d1f4 bp 0x7ffeb5906d50 sp 0x7ffeb5906500
|
||||
READ of size 1 at 0x6020000002ed thread T0
|
||||
SCARINESS: 12 (1-byte-read-heap-buffer-overflow)
|
||||
#0 0x49d1f3 in __interceptor_strncmp /j/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:407
|
||||
#1 0x5670f3 in strip_compression_suffix /j/tar/src/suffix.c:107
|
||||
#2 0x575788 in decode_options /j/tar/src/tar.c:2545
|
||||
#3 0x5760c0 in main /j/tar/src/tar.c:2708
|
||||
#4 0x7f105090df29 in __libc_start_main ../csu/libc-start.c:308
|
||||
#5 0x408629 in _start (/j/tar/src/tar+0x408629)
|
||||
|
||||
0x6020000002ed is located 3 bytes to the left of 6-byte region [0x6020000002f0,0x6020000002f6)
|
||||
allocated by thread T0 here:
|
||||
#0 0x4d0710 in __interceptor_malloc /j/gcc/libsanitizer/asan/asan_malloc_linux.cc:86
|
||||
#1 0x4908ad in __interceptor_strndup /j/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:326
|
||||
#2 0x5cbcbd in xstrndup /j/tar/gnu/xstrndup.c:32
|
||||
#3 0x5a325b in base_name /j/tar/gnu/basename.c:57
|
||||
#4 0x575772 in decode_options /j/tar/src/tar.c:2544
|
||||
#5 0x5760c0 in main /j/tar/src/tar.c:2708
|
||||
#6 0x7f105090df29 in __libc_start_main ../csu/libc-start.c:308
|
||||
---
|
||||
NEWS | 7 +++++--
|
||||
src/suffix.c | 11 +++++++----
|
||||
2 files changed, 12 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/suffix.c b/src/suffix.c
|
||||
index 66b5694..d787ea8 100644
|
||||
--- a/src/suffix.c
|
||||
+++ b/src/suffix.c
|
||||
@@ -62,7 +62,7 @@ find_compression_suffix (const char *name, size_t *ret_len)
|
||||
{
|
||||
size_t len;
|
||||
struct compression_suffix *p;
|
||||
-
|
||||
+
|
||||
suf++;
|
||||
len = strlen (suf);
|
||||
|
||||
@@ -101,10 +101,14 @@ strip_compression_suffix (const char *name)
|
||||
{
|
||||
char *s = NULL;
|
||||
size_t len;
|
||||
+ struct compression_suffix const *p = find_compression_suffix (name, &len);
|
||||
|
||||
- if (find_compression_suffix (name, &len))
|
||||
+ if (p)
|
||||
{
|
||||
- if (strncmp (name + len - 4, ".tar", 4) == 0)
|
||||
+ /* Strip an additional ".tar" suffix, but only if the just-stripped
|
||||
+ "outer" suffix did not begin with "t". */
|
||||
+ if (len > 4 && strncmp (name + len - 4, ".tar", 4) == 0
|
||||
+ && p->suffix[0] != 't')
|
||||
len -= 4;
|
||||
if (len == 0)
|
||||
return NULL;
|
||||
@@ -114,4 +118,3 @@ strip_compression_suffix (const char *name)
|
||||
}
|
||||
return s;
|
||||
}
|
||||
-
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -1,129 +0,0 @@
|
||||
From b451bfd224da44e93cf842f23455d755e48421dd Mon Sep 17 00:00:00 2001
|
||||
From: Pavel Raiskup <praiskup@redhat.com>
|
||||
Date: Mon, 28 Jul 2014 08:17:55 +0200
|
||||
Subject: [PATCH 8/9] Fix for infinite loops during sparse file handling
|
||||
|
||||
Upstream bugreport (still downstream):
|
||||
http://www.mail-archive.com/bug-tar@gnu.org/msg04432.html
|
||||
|
||||
Resolves: #1082608
|
||||
|
||||
---
|
||||
THANKS | 1 +
|
||||
src/sparse.c | 48 ++++++++++++++++++++++++++++++++----------------
|
||||
2 files changed, 33 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/THANKS b/THANKS
|
||||
index b4c5427..e74f71c 100644
|
||||
--- a/THANKS
|
||||
+++ b/THANKS
|
||||
@@ -175,6 +175,7 @@ Fabio d'Alessi cars@civ.bio.unipd.it
|
||||
Frank Heckenbach frank@g-n-u.de
|
||||
Frank Koenen koenfr@lidp.com
|
||||
Franz-Werner Gergen gergen@edvulx.mpi-stuttgart.mpg.de
|
||||
+François Ouellet fouell@gmail.com
|
||||
François Pinard pinard@iro.umontreal.ca
|
||||
Fritz Elfert fritz@fsun.triltsch.de
|
||||
George Chyu gschyu@ccgate.dp.beckman.com
|
||||
diff --git a/src/sparse.c b/src/sparse.c
|
||||
index 6a97676..53c1868 100644
|
||||
--- a/src/sparse.c
|
||||
+++ b/src/sparse.c
|
||||
@@ -301,6 +301,7 @@ sparse_dump_region (struct tar_sparse_file *file, size_t i)
|
||||
{
|
||||
union block *blk;
|
||||
off_t bytes_left = file->stat_info->sparse_map[i].numbytes;
|
||||
+ const char *file_name = file->stat_info->orig_file_name;
|
||||
|
||||
if (!lseek_or_error (file, file->stat_info->sparse_map[i].offset))
|
||||
return false;
|
||||
@@ -314,13 +315,23 @@ sparse_dump_region (struct tar_sparse_file *file, size_t i)
|
||||
bytes_read = safe_read (file->fd, blk->buffer, bufsize);
|
||||
if (bytes_read == SAFE_READ_ERROR)
|
||||
{
|
||||
- read_diag_details (file->stat_info->orig_file_name,
|
||||
+ read_diag_details (file_name,
|
||||
(file->stat_info->sparse_map[i].offset
|
||||
+ file->stat_info->sparse_map[i].numbytes
|
||||
- bytes_left),
|
||||
bufsize);
|
||||
return false;
|
||||
}
|
||||
+ if (bytes_read == 0)
|
||||
+ {
|
||||
+ char buf[UINTMAX_STRSIZE_BOUND];
|
||||
+ FATAL_ERROR ((0, 0,
|
||||
+ ngettext ("%s: File shrank by %s byte",
|
||||
+ "%s: File shrank by %s bytes",
|
||||
+ bytes_left),
|
||||
+ quotearg_colon (file_name),
|
||||
+ offtostr (bytes_left, buf)));
|
||||
+ }
|
||||
|
||||
memset (blk->buffer + bytes_read, 0, BLOCKSIZE - bytes_read);
|
||||
bytes_left -= bytes_read;
|
||||
@@ -475,33 +486,37 @@ sparse_skip_file (struct tar_stat_info *st)
|
||||
static bool
|
||||
check_sparse_region (struct tar_sparse_file *file, off_t beg, off_t end)
|
||||
{
|
||||
- if (!lseek_or_error (file, beg))
|
||||
+ off_t offset = beg;
|
||||
+
|
||||
+ if (!lseek_or_error (file, offset))
|
||||
return false;
|
||||
|
||||
- while (beg < end)
|
||||
+ while (offset < end)
|
||||
{
|
||||
size_t bytes_read;
|
||||
- size_t rdsize = BLOCKSIZE < end - beg ? BLOCKSIZE : end - beg;
|
||||
+ size_t rdsize = BLOCKSIZE < end - offset ? BLOCKSIZE : end - offset;
|
||||
char diff_buffer[BLOCKSIZE];
|
||||
|
||||
bytes_read = safe_read (file->fd, diff_buffer, rdsize);
|
||||
if (bytes_read == SAFE_READ_ERROR)
|
||||
{
|
||||
read_diag_details (file->stat_info->orig_file_name,
|
||||
- beg,
|
||||
- rdsize);
|
||||
- return false;
|
||||
- }
|
||||
- if (!zero_block_p (diff_buffer, bytes_read))
|
||||
- {
|
||||
- char begbuf[INT_BUFSIZE_BOUND (off_t)];
|
||||
- report_difference (file->stat_info,
|
||||
- _("File fragment at %s is not a hole"),
|
||||
- offtostr (beg, begbuf));
|
||||
+ offset, rdsize);
|
||||
return false;
|
||||
}
|
||||
|
||||
- beg += bytes_read;
|
||||
+ if (bytes_read == 0
|
||||
+ || !zero_block_p (diff_buffer, bytes_read))
|
||||
+ {
|
||||
+ char begbuf[INT_BUFSIZE_BOUND (off_t)];
|
||||
+ const char *msg = bytes_read ? _("File fragment at %s is not a hole")
|
||||
+ : _("Hole starting at %s is truncated");
|
||||
+
|
||||
+ report_difference (file->stat_info, msg, offtostr (beg, begbuf));
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ offset += bytes_read;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -542,7 +557,8 @@ check_data_region (struct tar_sparse_file *file, size_t i)
|
||||
file->dumped_size += bytes_read;
|
||||
size_left -= bytes_read;
|
||||
mv_size_left (file->stat_info->archive_file_size - file->dumped_size);
|
||||
- if (memcmp (blk->buffer, diff_buffer, rdsize))
|
||||
+ if (bytes_read == 0
|
||||
+ || memcmp (blk->buffer, diff_buffer, bytes_read))
|
||||
{
|
||||
report_difference (file->stat_info, _("Contents differ"));
|
||||
return false;
|
||||
--
|
||||
1.9.3
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
Per https://www.mail-archive.com/bug-tar@gnu.org/msg05440.html
|
||||
|
||||
diff --git a/tests/difflink.at b/tests/difflink.at
|
||||
index eadfb08..4e01176 100644
|
||||
--- a/tests/difflink.at
|
||||
+++ b/tests/difflink.at
|
||||
@@ -21,7 +21,7 @@ mkdir a
|
||||
genfile -f a/x
|
||||
ln -s x a/y
|
||||
ln a/y a/z
|
||||
-tar cf a.tar a
|
||||
+tar cf a.tar a/x a/y a/z
|
||||
rm a/z
|
||||
ln -s x a/z
|
||||
tar df a.tar
|
||||
@ -1,93 +0,0 @@
|
||||
From 298cfc4743b9cca6cc0c685b9fce5b34827bec1b Mon Sep 17 00:00:00 2001
|
||||
From: Pavel Raiskup <praiskup@redhat.com>
|
||||
Date: Thu, 4 Jan 2018 18:21:27 +0100
|
||||
Subject: [PATCH] tests: fix race in dirrem01 and dirrem02
|
||||
|
||||
Proposal:
|
||||
https://www.mail-archive.com/bug-tar@gnu.org/msg05451.html
|
||||
|
||||
Previously the '--checkpoint-action=echo' was triggered after
|
||||
'--checkpoint-action=sleep=1' - so the order of events *usually*
|
||||
was (for --format='gnu'):
|
||||
|
||||
...
|
||||
1. checkpoint handler before write of 'dir/sub' member
|
||||
2. one-second delay
|
||||
3. stderr write: 'tar: Write checkpoint 3'
|
||||
4. write the member 'dir/sub' into the archive
|
||||
5. check that the member's ctime has not been changed
|
||||
6. genfile's detecting 'Write checkpoint', doing unlink
|
||||
...
|
||||
|
||||
But sometimes, the genfile was fast enough to win the race and
|
||||
unlinked the directory before the member was written into the
|
||||
archive (IOW, the order was 1-2-3-6-4-5). This led to the
|
||||
occasional warning 'tar: dir/sub: file changed as we read it'.
|
||||
|
||||
Swap the order of 'sleep=1' and 'echo' actions so the genfile
|
||||
utility has (hopefully) enough time to do the unlink before
|
||||
writing the file into the archive (enforce 1-2-3-6-4-5 order).
|
||||
|
||||
* tests/dirrem01.at: Swap 'sleep=1' and 'echo' actions.
|
||||
* tests/dirrem02.at: Likewise.
|
||||
---
|
||||
tests/dirrem01.at | 5 +++--
|
||||
tests/dirrem02.at | 7 ++++---
|
||||
2 files changed, 7 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/tests/dirrem01.at b/tests/dirrem01.at
|
||||
index 40344dc..dabc206 100644
|
||||
--- a/tests/dirrem01.at
|
||||
+++ b/tests/dirrem01.at
|
||||
@@ -47,14 +47,15 @@ gnu) CPT=3;;
|
||||
esac
|
||||
|
||||
genfile --run --checkpoint=$CPT --unlink dir/sub/file2 --unlink dir/sub -- \
|
||||
- tar --blocking-factor=1 --checkpoint=1 --checkpoint-action='sleep=1' \
|
||||
- --checkpoint-action='echo' -c -f archive.tar \
|
||||
+ tar --blocking-factor=1 --checkpoint=1 --checkpoint-action='echo' \
|
||||
+ --checkpoint-action='sleep=1' -c -f archive.tar \
|
||||
--listed-incremental db -v dir >/dev/null
|
||||
],
|
||||
[1],
|
||||
[ignore],
|
||||
[tar: dir: Directory is new
|
||||
tar: dir/sub: Directory is new
|
||||
+tar: dir/sub: file changed as we read it
|
||||
tar: dir/sub: File removed before we read it
|
||||
],[],[],[gnu,posix])
|
||||
|
||||
diff --git a/tests/dirrem02.at b/tests/dirrem02.at
|
||||
index e1cf9ef..924454f 100644
|
||||
--- a/tests/dirrem02.at
|
||||
+++ b/tests/dirrem02.at
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
# Description:
|
||||
#
|
||||
-# When an explicitley named directory disappears during creation
|
||||
+# When an explicitly named directory disappears during creation
|
||||
# of incremental dump, tar should still exit with TAREXIT_FAILURE (2).
|
||||
#
|
||||
# For further details see dirrem01.at
|
||||
@@ -44,14 +44,15 @@ gnu) CPT=3;;
|
||||
esac
|
||||
|
||||
genfile --run --checkpoint=$CPT --unlink dir/sub/file2 --unlink dir/sub -- \
|
||||
- tar --blocking-factor=1 --checkpoint=1 --checkpoint-action='sleep=1' \
|
||||
- --checkpoint-action='echo' -c -f archive.tar \
|
||||
+ tar --blocking-factor=1 --checkpoint=1 --checkpoint-action='echo' \
|
||||
+ --checkpoint-action='sleep=1' -c -f archive.tar \
|
||||
--listed-incremental db -v dir dir/sub >/dev/null
|
||||
],
|
||||
[2],
|
||||
[ignore],
|
||||
[tar: dir: Directory is new
|
||||
tar: dir/sub: Directory is new
|
||||
+tar: dir/sub: file changed as we read it
|
||||
tar: dir/sub: Cannot open: No such file or directory
|
||||
tar: Exiting with failure status due to previous errors
|
||||
],[],[],[gnu,posix])
|
||||
--
|
||||
2.14.3
|
||||
|
||||
BIN
tar-1.30.tar.xz
BIN
tar-1.30.tar.xz
Binary file not shown.
@ -1,7 +0,0 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1.4.15 (GNU/Linux)
|
||||
|
||||
iEYEABECAAYFAlo2WDAACgkQNgKwf1XQxzLIAwCcCkJzqedt2FUq1N5ysPFomhvS
|
||||
SnIAnj+0Y7vNI1E4w/ektRMB/HTQceeK
|
||||
=TjVE
|
||||
-----END PGP SIGNATURE-----
|
||||
BIN
tar-1.32.tar.xz
Normal file
BIN
tar-1.32.tar.xz
Normal file
Binary file not shown.
7
tar-1.32.tar.xz.sig
Normal file
7
tar-1.32.tar.xz.sig
Normal file
@ -0,0 +1,7 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
|
||||
iG4EABECAC4WIQQyX2UMTCtq1YgHMno2ArB/VdDHMgUCXHFHdhAcZ3JheUBnbnUu
|
||||
b3JnLnVhAAoJEDYCsH9V0Mcy61oAni2Gwnao+qzsebDfH3ePo4FWdHKEAJ9IP8h7
|
||||
f96xDOstDrfKQjY/tqUrWg==
|
||||
=eh8f
|
||||
-----END PGP SIGNATURE-----
|
||||
33
tar.spec
33
tar.spec
@ -1,6 +1,6 @@
|
||||
Name: tar
|
||||
Version: 1.30
|
||||
Release: 11
|
||||
Version: 1.32
|
||||
Release: 1
|
||||
Epoch: 2
|
||||
Summary: An organized and systematic method of controlling a large amount of data
|
||||
License: GPLv3+
|
||||
@ -16,32 +16,6 @@ Patch0002: tar-1.28-vfatTruncate.patch
|
||||
Patch0003: tar-1.29-wildcards.patch
|
||||
Patch0004: tar-1.28-atime-rofs.patch
|
||||
Patch0005: tar-1.28-document-exclude-mistakes.patch
|
||||
Patch0006: tar-1.28-sparse-inf-loops.patch
|
||||
Patch0007: tar-1.30-tests-difflink.patch
|
||||
Patch0008: tar-1.30-tests-dirrem.patch
|
||||
|
||||
Patch0009: Rewrite-struct-tm-formatting.patch
|
||||
Patch0010: maint-avoid-warnings-from-upcoming-GCC8.patch
|
||||
Patch0011: maint-avoid-Wstringop-truncation-warnings-upcoming-G.patch
|
||||
Patch0012: maint-avoid-Wstringop-truncation-warnings-from-upcom.patch
|
||||
Patch0013: one-top-level-avoid-a-heap-buffer-overflow.patch
|
||||
Patch0014: Avoid-some-resource-leaks.patch
|
||||
Patch0015: Report-race-on-systems-without-O_DIRECTORY.patch
|
||||
Patch0016: Fix-double-free-introduced-by-577dc345.patch
|
||||
Patch0017: Fix-improper-memory-access.patch
|
||||
Patch0018: Fix-buffer-overflow.patch
|
||||
Patch0019: Reject-pax-options-starting-with-equals-sign.patch
|
||||
Patch0020: Fix-error-handling-when-reading-incremental-snapshot.patch
|
||||
Patch0021: Fix-semantics-of-K-used-together-with-explicit-membe.patch
|
||||
Patch0022: Bugfix.patch
|
||||
Patch0023: Disallow-modifications-to-the-global-pax-extended-he.patch
|
||||
Patch0024: Work-over-a-bug-in-gnulib-error.patch
|
||||
Patch0025: Remove-erroneous-abort-call.patch
|
||||
Patch0026: Fix-iconv-usage.patch
|
||||
Patch0027: Fix-compilation-without-iconv.patch
|
||||
Patch0028: Fix-build-on-AIX.patch
|
||||
Patch0029: Fix-possible-NULL-dereference-savannah-bug-55369.patch
|
||||
Patch0030: Fix-CVE-2018-20482.patch
|
||||
|
||||
%description
|
||||
GNU Tar provides the ability to create tar archives, as well as various other
|
||||
@ -100,6 +74,9 @@ make check
|
||||
%{_infodir}/tar.info*
|
||||
|
||||
%changelog
|
||||
* Mon Jul 27 2020 shixuantong <shixuantong> - 1.32-1
|
||||
- update to 1.32-1
|
||||
|
||||
* Tue Feb 18 2020 openEuler Buildteam <buildteam@openeuler.org> - 2:1.30-11
|
||||
- Enable check
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user