aboutsummaryrefslogtreecommitdiffstats
path: root/tar
diff options
context:
space:
mode:
authorMartin Matuska <mm@FreeBSD.org>2018-07-28 23:47:22 +0000
committerMartin Matuska <mm@FreeBSD.org>2018-07-28 23:47:22 +0000
commit0b7a6fc00bac0c873d5e00bc28ede661abc54f4e (patch)
treec23f0dc17d95dd8215e2314876db5a11ebd78578 /tar
parent032a8914c1034da8875307405dfd591a1b96137c (diff)
downloadsrc-0b7a6fc00bac0c873d5e00bc28ede661abc54f4e.tar.gz
src-0b7a6fc00bac0c873d5e00bc28ede661abc54f4e.zip
Update vendor/libarchive/dist to git 2c8c83b9731ff822fad6cc8c670ea5519c366a14
Important vendor changes: PR #993: Chdir to -C directory for metalog processing OSS-Fuzz #4969: Check size of the extended time field in zip archives PR #973: Record informational compression level in gzip header
Notes
Notes: svn path=/vendor/libarchive/dist/; revision=336851
Diffstat (limited to 'tar')
-rw-r--r--tar/bsdtar.c2
-rw-r--r--tar/test/CMakeLists.txt1
-rw-r--r--tar/test/test_option_C_mtree.c73
-rw-r--r--tar/test/test_option_fflags.c4
-rw-r--r--tar/write.c2
5 files changed, 80 insertions, 2 deletions
diff --git a/tar/bsdtar.c b/tar/bsdtar.c
index 11dedbf9c26a..963bd4f9ad5e 100644
--- a/tar/bsdtar.c
+++ b/tar/bsdtar.c
@@ -920,7 +920,7 @@ usage(void)
static void
version(void)
{
- printf("bsdtar %s - %s\n",
+ printf("bsdtar %s - %s \n",
BSDTAR_VERSION_STRING,
archive_version_details());
exit(0);
diff --git a/tar/test/CMakeLists.txt b/tar/test/CMakeLists.txt
index eacbabef1af0..d7de42d6ab62 100644
--- a/tar/test/CMakeLists.txt
+++ b/tar/test/CMakeLists.txt
@@ -28,6 +28,7 @@ IF(ENABLE_TAR AND ENABLE_TEST)
test_leading_slash.c
test_missing_file.c
test_option_C_upper.c
+ test_option_C_mtree.c
test_option_H_upper.c
test_option_L_upper.c
test_option_O_upper.c
diff --git a/tar/test/test_option_C_mtree.c b/tar/test/test_option_C_mtree.c
new file mode 100644
index 000000000000..caf8044bf932
--- /dev/null
+++ b/tar/test/test_option_C_mtree.c
@@ -0,0 +1,73 @@
+/*-
+ * Copyright (c) 2018 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Arshan Khanifar <arshankhanifar@gmail.com>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_option_C_mtree)
+{
+ char *p0;
+ size_t s;
+ int r;
+ p0 = NULL;
+ char *content = "./foo type=file uname=root gname=root mode=0755\n";
+ char *filename = "output.tar";
+
+ /* an absolute path to mtree file */
+ char *mtree_file = "/METALOG.mtree";
+ char *absolute_path = malloc(strlen(testworkdir) + strlen(mtree_file) + 1);
+ strcpy(absolute_path, testworkdir);
+ strcat(absolute_path, mtree_file );
+
+ /* Create an archive using an mtree file. */
+ assertMakeFile(absolute_path, 0777, content);
+ assertMakeDir("bar", 0775);
+ assertMakeFile("bar/foo", 0777, "abc");
+
+ r = systemf("%s -cf %s -C bar \"@%s\" >step1.out 2>step1.err", testprog, filename, absolute_path);
+
+ failure("Error invoking %s -cf %s -C bar @%s", testprog, filename, absolute_path);
+ assertEqualInt(r, 0);
+ assertEmptyFile("step1.out");
+ assertEmptyFile("step1.err");
+
+ /* Do validation of the constructed archive. */
+
+ p0 = slurpfile(&s, "output.tar");
+ if (!assert(p0 != NULL))
+ goto done;
+ if (!assert(s >= 2048))
+ goto done;
+ assertEqualMem(p0 + 0, "./foo", 5);
+ assertEqualMem(p0 + 512, "abc", 3);
+ assertEqualMem(p0 + 1024, "\0\0\0\0\0\0\0\0", 8);
+ assertEqualMem(p0 + 1536, "\0\0\0\0\0\0\0\0", 8);
+done:
+ free(p0);
+}
+
+
diff --git a/tar/test/test_option_fflags.c b/tar/test/test_option_fflags.c
index 77a4e3e19f0f..f223feb19069 100644
--- a/tar/test/test_option_fflags.c
+++ b/tar/test/test_option_fflags.c
@@ -25,6 +25,10 @@
#include "test.h"
__FBSDID("$FreeBSD$");
+#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__)
+#define chmod _chmod
+#endif
+
static void
clear_fflags(const char *pathname)
{
diff --git a/tar/write.c b/tar/write.c
index 9c2456625271..e15cc06ccfc4 100644
--- a/tar/write.c
+++ b/tar/write.c
@@ -503,7 +503,7 @@ write_archive(struct archive *a, struct bsdtar *bsdtar)
}
set_chdir(bsdtar, arg);
} else {
- if (*arg != '/' && (arg[0] != '@' || arg[1] != '/'))
+ if (*arg != '/')
do_chdir(bsdtar); /* Handle a deferred -C */
if (*arg == '@') {
if (append_archive_filename(bsdtar, a,