aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Matuska <mm@FreeBSD.org>2016-10-04 11:44:21 +0000
committerMartin Matuska <mm@FreeBSD.org>2016-10-04 11:44:21 +0000
commitadb01b286db1dc63ea40381f42f6124b9e695253 (patch)
tree34ca5744d8d31a6f502d9f4b122da8606a044b2e
parent282f8bd6960fef410b548a8bec8f3f3ddfb3498c (diff)
downloadsrc-adb01b286db1dc63ea40381f42f6124b9e695253.tar.gz
src-adb01b286db1dc63ea40381f42f6124b9e695253.zip
Update vendor/libarchive to git 024be27d1b299c030e8841bed3002ee07ba9eedc
Important vendor bugfixes (relevant to FreeBSD): #747: Out of bounds read in mtree parser #761: heap-based buffer overflow in read_Header (7-zip) #784: Invalid file on bsdtar command line results in internal errors (1) PR: 213092 (1) Obtained from: https://github.com/libarchive/libarchive
Notes
Notes: svn path=/vendor/libarchive/dist/; revision=306669
-rw-r--r--Makefile.am1
-rw-r--r--cat/test/main.c39
-rw-r--r--cat/test/test.h1
-rw-r--r--cpio/test/main.c39
-rw-r--r--cpio/test/test.h1
-rw-r--r--examples/minitar/minitar.c8
-rw-r--r--libarchive/archive_read_support_format_7zip.c10
-rw-r--r--libarchive/archive_read_support_format_mtree.c11
-rw-r--r--libarchive/test/CMakeLists.txt1
-rw-r--r--libarchive/test/main.c14
-rw-r--r--libarchive/test/test_acl_freebsd_nfs4.c2
-rw-r--r--libarchive/test/test_read_format_mtree_crash747.c44
-rw-r--r--libarchive/test/test_read_format_mtree_crash747.mtree.bz2.uu6
-rw-r--r--libarchive/test/test_read_set_format.c2
-rw-r--r--tar/subst.c1
-rw-r--r--tar/test/main.c46
-rw-r--r--tar/test/test.h4
-rw-r--r--tar/test/test_option_H_upper.c4
-rw-r--r--tar/test/test_option_L_upper.c12
-rw-r--r--tar/test/test_option_U_upper.c4
-rw-r--r--tar/test/test_option_n.c2
-rw-r--r--tar/write.c2
22 files changed, 227 insertions, 27 deletions
diff --git a/Makefile.am b/Makefile.am
index e161c5d3be4c..90c9ae10546f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -449,6 +449,7 @@ libarchive_test_SOURCES= \
libarchive/test/test_read_format_lha_bugfix_0.c \
libarchive/test/test_read_format_lha_filename.c \
libarchive/test/test_read_format_mtree.c \
+ libarchive/test/test_read_format_mtree_crash747.c \
libarchive/test/test_read_format_pax_bz2.c \
libarchive/test/test_read_format_rar.c \
libarchive/test/test_read_format_rar_encryption_data.c \
diff --git a/cat/test/main.c b/cat/test/main.c
index 0aa1deb572b3..29f7b14b1849 100644
--- a/cat/test/main.c
+++ b/cat/test/main.c
@@ -1360,6 +1360,31 @@ assertion_file_birthtime_recent(const char *file, int line,
return assertion_file_time(file, line, pathname, 0, 0, 'b', 1);
}
+/* Verify mode of 'pathname'. */
+int
+assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode)
+{
+ int mode;
+ int r;
+
+ assertion_count(file, line);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ failure_start(file, line, "assertFileMode not yet implemented for Windows");
+#else
+ {
+ struct stat st;
+ r = lstat(pathname, &st);
+ mode = (int)(st.st_mode & 0777);
+ }
+ if (r == 0 && mode == expected_mode)
+ return (1);
+ failure_start(file, line, "File %s has mode %o, expected %o",
+ pathname, mode, expected_mode);
+#endif
+ failure_finish(NULL);
+ return (0);
+}
+
/* Verify mtime of 'pathname'. */
int
assertion_file_mtime(const char *file, int line,
@@ -1578,8 +1603,12 @@ assertion_make_dir(const char *file, int line, const char *dirname, int mode)
if (0 == _mkdir(dirname))
return (1);
#else
- if (0 == mkdir(dirname, mode))
- return (1);
+ if (0 == mkdir(dirname, mode)) {
+ if (0 == chmod(dirname, mode)) {
+ assertion_file_mode(file, line, dirname, mode);
+ return (1);
+ }
+ }
#endif
failure_start(file, line, "Could not create directory %s", dirname);
failure_finish(NULL);
@@ -1628,6 +1657,11 @@ assertion_make_file(const char *file, int line,
failure_finish(NULL);
return (0);
}
+ if (0 != chmod(path, mode)) {
+ failure_start(file, line, "Could not chmod %s", path);
+ failure_finish(NULL);
+ return (0);
+ }
if (contents != NULL) {
ssize_t wsize;
@@ -1644,6 +1678,7 @@ assertion_make_file(const char *file, int line,
}
}
close(fd);
+ assertion_file_mode(file, line, path, mode);
return (1);
#endif
}
diff --git a/cat/test/test.h b/cat/test/test.h
index c5d2363040f8..1d219647560f 100644
--- a/cat/test/test.h
+++ b/cat/test/test.h
@@ -241,6 +241,7 @@ int assertion_file_birthtime_recent(const char *, int, const char *);
int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **);
int assertion_file_contents(const char *, int, const void *, int, const char *);
int assertion_file_exists(const char *, int, const char *);
+int assertion_file_mode(const char *, int, const char *, int);
int assertion_file_mtime(const char *, int, const char *, long, long);
int assertion_file_mtime_recent(const char *, int, const char *);
int assertion_file_nlinks(const char *, int, const char *, int);
diff --git a/cpio/test/main.c b/cpio/test/main.c
index 1c9ae6e2be54..29bbc37a46bb 100644
--- a/cpio/test/main.c
+++ b/cpio/test/main.c
@@ -1361,6 +1361,31 @@ assertion_file_birthtime_recent(const char *file, int line,
return assertion_file_time(file, line, pathname, 0, 0, 'b', 1);
}
+/* Verify mode of 'pathname'. */
+int
+assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode)
+{
+ int mode;
+ int r;
+
+ assertion_count(file, line);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ failure_start(file, line, "assertFileMode not yet implemented for Windows");
+#else
+ {
+ struct stat st;
+ r = lstat(pathname, &st);
+ mode = (int)(st.st_mode & 0777);
+ }
+ if (r == 0 && mode == expected_mode)
+ return (1);
+ failure_start(file, line, "File %s has mode %o, expected %o",
+ pathname, mode, expected_mode);
+#endif
+ failure_finish(NULL);
+ return (0);
+}
+
/* Verify mtime of 'pathname'. */
int
assertion_file_mtime(const char *file, int line,
@@ -1579,8 +1604,12 @@ assertion_make_dir(const char *file, int line, const char *dirname, int mode)
if (0 == _mkdir(dirname))
return (1);
#else
- if (0 == mkdir(dirname, mode))
- return (1);
+ if (0 == mkdir(dirname, mode)) {
+ if (0 == chmod(dirname, mode)) {
+ assertion_file_mode(file, line, dirname, mode);
+ return (1);
+ }
+ }
#endif
failure_start(file, line, "Could not create directory %s", dirname);
failure_finish(NULL);
@@ -1629,6 +1658,11 @@ assertion_make_file(const char *file, int line,
failure_finish(NULL);
return (0);
}
+ if (0 != chmod(path, mode)) {
+ failure_start(file, line, "Could not chmod %s", path);
+ failure_finish(NULL);
+ return (0);
+ }
if (contents != NULL) {
ssize_t wsize;
@@ -1645,6 +1679,7 @@ assertion_make_file(const char *file, int line,
}
}
close(fd);
+ assertion_file_mode(file, line, path, mode);
return (1);
#endif
}
diff --git a/cpio/test/test.h b/cpio/test/test.h
index 606b121bba6e..ecc6f27911b2 100644
--- a/cpio/test/test.h
+++ b/cpio/test/test.h
@@ -241,6 +241,7 @@ int assertion_file_birthtime_recent(const char *, int, const char *);
int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **);
int assertion_file_contents(const char *, int, const void *, int, const char *);
int assertion_file_exists(const char *, int, const char *);
+int assertion_file_mode(const char *, int, const char *, int);
int assertion_file_mtime(const char *, int, const char *, long, long);
int assertion_file_mtime_recent(const char *, int, const char *);
int assertion_file_nlinks(const char *, int, const char *, int);
diff --git a/examples/minitar/minitar.c b/examples/minitar/minitar.c
index 81e5e11c7985..0b4b4147ca99 100644
--- a/examples/minitar/minitar.c
+++ b/examples/minitar/minitar.c
@@ -222,7 +222,6 @@ static void
create(const char *filename, int compress, const char **argv)
{
struct archive *a;
- struct archive *disk;
struct archive_entry *entry;
ssize_t len;
int fd;
@@ -253,12 +252,11 @@ create(const char *filename, int compress, const char **argv)
filename = NULL;
archive_write_open_filename(a, filename);
- disk = archive_read_disk_new();
-#ifndef NO_LOOKUP
- archive_read_disk_set_standard_lookup(disk);
-#endif
while (*argv != NULL) {
struct archive *disk = archive_read_disk_new();
+#ifndef NO_LOOKUP
+ archive_read_disk_set_standard_lookup(disk);
+#endif
int r;
r = archive_read_disk_open(disk, *argv);
diff --git a/libarchive/archive_read_support_format_7zip.c b/libarchive/archive_read_support_format_7zip.c
index 1dfe52b8539a..c0a536c4a981 100644
--- a/libarchive/archive_read_support_format_7zip.c
+++ b/libarchive/archive_read_support_format_7zip.c
@@ -2431,6 +2431,8 @@ read_Header(struct archive_read *a, struct _7z_header_info *h,
switch (type) {
case kEmptyStream:
+ if (h->emptyStreamBools != NULL)
+ return (-1);
h->emptyStreamBools = calloc((size_t)zip->numFiles,
sizeof(*h->emptyStreamBools));
if (h->emptyStreamBools == NULL)
@@ -2451,6 +2453,8 @@ read_Header(struct archive_read *a, struct _7z_header_info *h,
return (-1);
break;
}
+ if (h->emptyFileBools != NULL)
+ return (-1);
h->emptyFileBools = calloc(empty_streams,
sizeof(*h->emptyFileBools));
if (h->emptyFileBools == NULL)
@@ -2465,6 +2469,8 @@ read_Header(struct archive_read *a, struct _7z_header_info *h,
return (-1);
break;
}
+ if (h->antiBools != NULL)
+ return (-1);
h->antiBools = calloc(empty_streams,
sizeof(*h->antiBools));
if (h->antiBools == NULL)
@@ -2491,6 +2497,8 @@ read_Header(struct archive_read *a, struct _7z_header_info *h,
if ((ll & 1) || ll < zip->numFiles * 4)
return (-1);
+ if (zip->entry_names != NULL)
+ return (-1);
zip->entry_names = malloc(ll);
if (zip->entry_names == NULL)
return (-1);
@@ -2543,6 +2551,8 @@ read_Header(struct archive_read *a, struct _7z_header_info *h,
if ((p = header_bytes(a, 2)) == NULL)
return (-1);
allAreDefined = *p;
+ if (h->attrBools != NULL)
+ return (-1);
h->attrBools = calloc((size_t)zip->numFiles,
sizeof(*h->attrBools));
if (h->attrBools == NULL)
diff --git a/libarchive/archive_read_support_format_mtree.c b/libarchive/archive_read_support_format_mtree.c
index 8c3be9a294f8..ae58e8750534 100644
--- a/libarchive/archive_read_support_format_mtree.c
+++ b/libarchive/archive_read_support_format_mtree.c
@@ -301,6 +301,15 @@ get_line_size(const char *b, ssize_t avail, ssize_t *nlsize)
return (avail);
}
+/*
+ * <---------------- ravail --------------------->
+ * <-- diff ------> <--- avail ----------------->
+ * <---- len ----------->
+ * | Previous lines | line being parsed nl extra |
+ * ^
+ * b
+ *
+ */
static ssize_t
next_line(struct archive_read *a,
const char **b, ssize_t *avail, ssize_t *ravail, ssize_t *nl)
@@ -339,7 +348,7 @@ next_line(struct archive_read *a,
*b += diff;
*avail -= diff;
tested = len;/* Skip some bytes we already determinated. */
- len = get_line_size(*b, *avail, nl);
+ len = get_line_size(*b + len, *avail - len, nl);
if (len >= 0)
len += tested;
}
diff --git a/libarchive/test/CMakeLists.txt b/libarchive/test/CMakeLists.txt
index 345e42af2fc7..0cb5966df35c 100644
--- a/libarchive/test/CMakeLists.txt
+++ b/libarchive/test/CMakeLists.txt
@@ -138,6 +138,7 @@ IF(ENABLE_TEST)
test_read_format_lha_bugfix_0.c
test_read_format_lha_filename.c
test_read_format_mtree.c
+ test_read_format_mtree_crash747.c
test_read_format_pax_bz2.c
test_read_format_rar.c
test_read_format_rar_encryption_data.c
diff --git a/libarchive/test/main.c b/libarchive/test/main.c
index 9fa26fbf8640..2fec9396314f 100644
--- a/libarchive/test/main.c
+++ b/libarchive/test/main.c
@@ -1607,8 +1607,12 @@ assertion_make_dir(const char *file, int line, const char *dirname, int mode)
if (0 == _mkdir(dirname))
return (1);
#else
- if (0 == mkdir(dirname, mode))
- return (1);
+ if (0 == mkdir(dirname, mode)) {
+ if (0 == chmod(dirname, mode)) {
+ assertion_file_mode(file, line, dirname, mode);
+ return (1);
+ }
+ }
#endif
failure_start(file, line, "Could not create directory %s", dirname);
failure_finish(NULL);
@@ -1657,6 +1661,11 @@ assertion_make_file(const char *file, int line,
failure_finish(NULL);
return (0);
}
+ if (0 != chmod(path, mode)) {
+ failure_start(file, line, "Could not chmod %s", path);
+ failure_finish(NULL);
+ return (0);
+ }
if (contents != NULL) {
ssize_t wsize;
@@ -1673,6 +1682,7 @@ assertion_make_file(const char *file, int line,
}
}
close(fd);
+ assertion_file_mode(file, line, path, mode);
return (1);
#endif
}
diff --git a/libarchive/test/test_acl_freebsd_nfs4.c b/libarchive/test/test_acl_freebsd_nfs4.c
index fd2301d1f3dd..89861d6eadf9 100644
--- a/libarchive/test/test_acl_freebsd_nfs4.c
+++ b/libarchive/test/test_acl_freebsd_nfs4.c
@@ -93,7 +93,7 @@ static struct myacl_t acls_reg[] = {
static struct myacl_t acls_dir[] = {
/* For this test, we need to be able to read and write the ACL. */
- { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_ACL,
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_READ_ACL,
ARCHIVE_ENTRY_ACL_USER_OBJ, -1, ""},
/* An entry for each type. */
diff --git a/libarchive/test/test_read_format_mtree_crash747.c b/libarchive/test/test_read_format_mtree_crash747.c
new file mode 100644
index 000000000000..c08284552131
--- /dev/null
+++ b/libarchive/test/test_read_format_mtree_crash747.c
@@ -0,0 +1,44 @@
+/*-
+ * Copyright (c) 2003-2016 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+
+
+/*
+ * Reproduce the crash reported in Github Issue #747.
+ */
+DEFINE_TEST(test_read_format_mtree_crash747)
+{
+ const char *reffile = "test_read_format_mtree_crash747.mtree.bz2";
+ struct archive *a;
+
+ extract_reference_file(reffile);
+
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_bzip2(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_mtree(a));
+ assertEqualIntA(a, ARCHIVE_FATAL, archive_read_open_filename(a, reffile, 10240));
+ assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
+
diff --git a/libarchive/test/test_read_format_mtree_crash747.mtree.bz2.uu b/libarchive/test/test_read_format_mtree_crash747.mtree.bz2.uu
new file mode 100644
index 000000000000..84f38955b8a5
--- /dev/null
+++ b/libarchive/test/test_read_format_mtree_crash747.mtree.bz2.uu
@@ -0,0 +1,6 @@
+begin 600 test_read_format_mtree_crash747.mtree.bz2
+M0EIH.3%!62936:OH@(@``'/[@,`0`@!``'^```)A@9\`$`@@`'4)049!IIH!
+MM021-0,F@&@6````9%>$(K!GIC*XFR0`$```J0+:$XP```!D-F)H[#SE9+2'
+4+E"L=ASXUI%R(I"HD'ZA(5?1`Q``
+`
+end
diff --git a/libarchive/test/test_read_set_format.c b/libarchive/test/test_read_set_format.c
index 9208833e53a7..f9be978351c4 100644
--- a/libarchive/test/test_read_set_format.c
+++ b/libarchive/test/test_read_set_format.c
@@ -204,7 +204,7 @@ DEFINE_TEST(test_read_append_filter_wrong_program)
/*
* If we have "bunzip2 -q", try using that.
*/
- if (!canRunCommand("bunzip2 -V")) {
+ if (!canRunCommand("bunzip2 -h")) {
skipping("Can't run bunzip2 program on this platform");
return;
}
diff --git a/tar/subst.c b/tar/subst.c
index 4710e06a623a..39c54acfd14f 100644
--- a/tar/subst.c
+++ b/tar/subst.c
@@ -84,6 +84,7 @@ add_substitution(struct bsdtar *bsdtar, const char *rule_text)
if (rule == NULL)
lafe_errc(1, errno, "Out of memory");
rule->next = NULL;
+ rule->result = NULL;
if (subst->last_rule == NULL)
subst->first_rule = rule;
diff --git a/tar/test/main.c b/tar/test/main.c
index 08ac6277370a..a9300d3f2b24 100644
--- a/tar/test/main.c
+++ b/tar/test/main.c
@@ -130,6 +130,13 @@ __FBSDID("$FreeBSD: src/usr.bin/tar/test/main.c,v 1.6 2008/11/05 06:40:53 kientz
# include <crtdbg.h>
#endif
+mode_t umasked(mode_t expected_mode)
+{
+ mode_t mode = umask(0);
+ umask(mode);
+ return expected_mode & ~mode;
+}
+
/* Path to working directory for current test */
const char *testworkdir;
#ifdef PROGRAM
@@ -1361,6 +1368,31 @@ assertion_file_birthtime_recent(const char *file, int line,
return assertion_file_time(file, line, pathname, 0, 0, 'b', 1);
}
+/* Verify mode of 'pathname'. */
+int
+assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode)
+{
+ int mode;
+ int r;
+
+ assertion_count(file, line);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ failure_start(file, line, "assertFileMode not yet implemented for Windows");
+#else
+ {
+ struct stat st;
+ r = lstat(pathname, &st);
+ mode = (int)(st.st_mode & 0777);
+ }
+ if (r == 0 && mode == expected_mode)
+ return (1);
+ failure_start(file, line, "File %s has mode %o, expected %o",
+ pathname, mode, expected_mode);
+#endif
+ failure_finish(NULL);
+ return (0);
+}
+
/* Verify mtime of 'pathname'. */
int
assertion_file_mtime(const char *file, int line,
@@ -1579,8 +1611,12 @@ assertion_make_dir(const char *file, int line, const char *dirname, int mode)
if (0 == _mkdir(dirname))
return (1);
#else
- if (0 == mkdir(dirname, mode))
- return (1);
+ if (0 == mkdir(dirname, mode)) {
+ if (0 == chmod(dirname, mode)) {
+ assertion_file_mode(file, line, dirname, mode);
+ return (1);
+ }
+ }
#endif
failure_start(file, line, "Could not create directory %s", dirname);
failure_finish(NULL);
@@ -1629,6 +1665,11 @@ assertion_make_file(const char *file, int line,
failure_finish(NULL);
return (0);
}
+ if (0 != chmod(path, mode)) {
+ failure_start(file, line, "Could not chmod %s", path);
+ failure_finish(NULL);
+ return (0);
+ }
if (contents != NULL) {
ssize_t wsize;
@@ -1645,6 +1686,7 @@ assertion_make_file(const char *file, int line,
}
}
close(fd);
+ assertion_file_mode(file, line, path, mode);
return (1);
#endif
}
diff --git a/tar/test/test.h b/tar/test/test.h
index 704a137ed3fb..dbf9f2de076e 100644
--- a/tar/test/test.h
+++ b/tar/test/test.h
@@ -241,6 +241,7 @@ int assertion_file_birthtime_recent(const char *, int, const char *);
int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **);
int assertion_file_contents(const char *, int, const void *, int, const char *);
int assertion_file_exists(const char *, int, const char *);
+int assertion_file_mode(const char *, int, const char *, int);
int assertion_file_mtime(const char *, int, const char *, long, long);
int assertion_file_mtime_recent(const char *, int, const char *);
int assertion_file_nlinks(const char *, int, const char *, int);
@@ -326,6 +327,9 @@ void copy_reference_file(const char *);
*/
void extract_reference_files(const char **);
+/* Subtract umask from mode */
+mode_t umasked(mode_t expected_mode);
+
/* Path to working directory for current test */
extern const char *testworkdir;
diff --git a/tar/test/test_option_H_upper.c b/tar/test/test_option_H_upper.c
index 7ddd917b7b94..adc294b55b26 100644
--- a/tar/test/test_option_H_upper.c
+++ b/tar/test/test_option_H_upper.c
@@ -83,10 +83,10 @@ DEFINE_TEST(test_option_H_upper)
assertChdir("test3");
assertEqualInt(0,
systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
- assertIsDir("ld1", 0755);
+ assertIsDir("ld1", umasked(0755));
assertIsSymlink("d1/linkX", "fileX");
assertIsSymlink("d1/link1", "file1");
- assertIsReg("link2", 0644);
+ assertIsReg("link2", umasked(0644));
assertIsSymlink("linkY", "d1/fileY");
assertChdir("..");
}
diff --git a/tar/test/test_option_L_upper.c b/tar/test/test_option_L_upper.c
index 57abe412cd2d..f5a3c5ab4cba 100644
--- a/tar/test/test_option_L_upper.c
+++ b/tar/test/test_option_L_upper.c
@@ -69,10 +69,10 @@ DEFINE_TEST(test_option_L_upper)
assertChdir("test2");
assertEqualInt(0,
systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
- assertIsDir("ld1", 0755);
- assertIsReg("d1/link1", 0644);
+ assertIsDir("ld1", umasked(0755));
+ assertIsReg("d1/link1", umasked(0644));
assertIsSymlink("d1/linkX", "fileX");
- assertIsReg("link2", 0644);
+ assertIsReg("link2", umasked(0644));
assertIsSymlink("linkY", "d1/fileY");
assertChdir("..");
@@ -83,10 +83,10 @@ DEFINE_TEST(test_option_L_upper)
assertChdir("test3");
assertEqualInt(0,
systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
- assertIsDir("ld1", 0755);
- assertIsReg("d1/link1", 0644);
+ assertIsDir("ld1", umasked(0755));
+ assertIsReg("d1/link1", umasked(0644));
assertIsSymlink("d1/linkX", "fileX");
- assertIsReg("link2", 0644);
+ assertIsReg("link2", umasked(0644));
assertIsSymlink("linkY", "d1/fileY");
assertChdir("..");
}
diff --git a/tar/test/test_option_U_upper.c b/tar/test/test_option_U_upper.c
index 4d77cb03810a..2c43e002df5b 100644
--- a/tar/test/test_option_U_upper.c
+++ b/tar/test/test_option_U_upper.c
@@ -135,7 +135,7 @@ DEFINE_TEST(test_option_U_upper)
assertMakeSymlink("d1/file1", "d1/realfile1");
assertEqualInt(0,
systemf("%s -xf ../archive.tar d1/file1 >test.out 2>test.err", testprog));
- assertIsReg("d1/file1", 0644);
+ assertIsReg("d1/file1", umasked(0644));
assertFileContents("d1/file1", 8, "d1/file1");
assertFileContents("realfile1", 9, "d1/realfile1");
assertEmptyFile("test.out");
@@ -150,7 +150,7 @@ DEFINE_TEST(test_option_U_upper)
assertMakeSymlink("d1/file1", "d1/realfile1");
assertEqualInt(0,
systemf("%s -xPUf ../archive.tar d1/file1 >test.out 2>test.err", testprog));
- assertIsReg("d1/file1", 0644);
+ assertIsReg("d1/file1", umasked(0644));
assertFileContents("d1/file1", 8, "d1/file1");
assertFileContents("realfile1", 9, "d1/realfile1");
assertEmptyFile("test.out");
diff --git a/tar/test/test_option_n.c b/tar/test/test_option_n.c
index 4017dd9f01fd..18ab6142d0f2 100644
--- a/tar/test/test_option_n.c
+++ b/tar/test/test_option_n.c
@@ -55,7 +55,7 @@ DEFINE_TEST(test_option_n)
systemf("%s -xf archive.tar >x.out 2>x.err", testprog));
assertEmptyFile("x.out");
assertEmptyFile("x.err");
- assertIsDir("d1", 0755);
+ assertIsDir("d1", umasked(0755));
assertFileNotExists("d1/file1");
assertChdir("..");
}
diff --git a/tar/write.c b/tar/write.c
index 2d076f488b55..da5a128254fa 100644
--- a/tar/write.c
+++ b/tar/write.c
@@ -886,6 +886,8 @@ write_hierarchy(struct bsdtar *bsdtar, struct archive *a, const char *path)
"%s", archive_error_string(disk));
if (r == ARCHIVE_FATAL || r == ARCHIVE_FAILED) {
bsdtar->return_value = 1;
+ archive_entry_free(entry);
+ archive_read_close(disk);
return;
} else if (r < ARCHIVE_WARN)
continue;