Extensive improvements to the libarchive_test test program that

exercises and verifies the libarchive APIs:

* Improved error reporting; hexdumps are now provided for
  many file/memory content differences.
* Overall status more clearly counts "tests" and "assertions"
* Reference files can now be stored on disk instead of having
  to be compiled into the test program itself.  A couple of
  tests have been converted to this more natural structure.
* Several memory leaks corrected so that leaks within libarchive
  itself can be more easily detected and diagnosed.
* New test: GNU tar compatibility
* New test: Zip compatibility
* New test: Zero-byte writes to a compressed archive entry
* New test: archive_entry_strmode() format verification
* New test: mtree reader
* New test: write/read of large (2G - 1TB) entries to tar archives
  (thanks to recent performance work, this test only requires a few seconds)
* New test: detailed format verification of cpio odc and newc writers
* Many minor additions/improvements to existing tests as well.
This commit is contained in:
Tim Kientzle 2008-01-01 22:28:04 +00:00
parent 190267c967
commit 2a5e8d812c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=175044
29 changed files with 3336 additions and 804 deletions

View File

@ -1,11 +1,32 @@
# $FreeBSD$
# Where to find the libarchive sources
LA_SRCDIR=${.CURDIR}/..
.PATH: ${LA_SRCDIR}
# Get a list of all libarchive source files
LA_SRCS!=make -f ${LA_SRCDIR}/Makefile -V SRCS
TESTFILES= \
test_compat_gtar_1.tgz \
test_compat_zip_1.zip \
test_read_format_gtar_sparse_1_13.tgz \
test_read_format_gtar_sparse_1_17.tgz \
test_read_format_gtar_sparse_1_17_posix00.tgz \
test_read_format_gtar_sparse_1_17_posix01.tgz \
test_read_format_gtar_sparse_1_17_posix10.tgz \
test_read_format_gtar_sparse_1_17_posix10_modified.tar
TESTS= \
test_acl_basic.c \
test_acl_pax.c \
test_archive_api_feature.c \
test_bad_fd.c \
test_compat_gtar.c \
test_compat_zip.c \
test_empty_write.c \
test_entry.c \
test_entry_strmode.c \
test_read_compress_program.c \
test_read_data_large.c \
test_read_extract.c \
@ -22,6 +43,7 @@ TESTS= \
test_read_format_gtar_sparse.c \
test_read_format_iso_gz.c \
test_read_format_isorr_bz2.c \
test_read_format_mtree.c \
test_read_format_pax_bz2.c \
test_read_format_tar.c \
test_read_format_tbz.c \
@ -33,50 +55,74 @@ TESTS= \
test_read_position.c \
test_read_truncated.c \
test_tar_filenames.c \
test_tar_large.c \
test_write_compress_program.c \
test_write_disk.c \
test_write_disk_perms.c \
test_write_disk_secure.c \
test_write_format_ar.c \
test_write_format_cpio.c \
test_write_format_cpio_odc.c \
test_write_format_cpio_newc.c \
test_write_format_cpio_empty.c \
test_write_format_shar_empty.c \
test_write_format_tar.c \
test_write_format_tar_empty.c \
test_write_open_memory.c
SRCS= ${TESTS} \
# Build the test program using all libarchive sources + the test sources.
SRCS= ${LA_SRCS} \
${TESTS} \
list.h \
main.c \
read_open_memory.c
CLEANFILES+= list.h
CLEANFILES+= list.h archive.h
NO_MAN=yes
PROG=libarchive_test
DPADD=${LIBARCHIVE} ${LIBBZ2} ${LIBZ}
LDADD= -larchive -lz -lbz2
INTERNALPROG=yes # Don't install this; it's just for testing
DPADD=${LIBBZ2} ${LIBZ}
CFLAGS+= -DPLATFORM_CONFIG_H=\"config_freebsd.h\"
LDADD= -lz -lbz2
CFLAGS+= -static -g
CFLAGS+= -I${.OBJDIR}
CFLAGS+= -I${.CURDIR}
CFLAGS+= -I${LA_SRCDIR}
# Without this, libarchive source files find archive.h in LA_SRCDIR,
# which may not be the same as archive.h in the test dir.
CFLAGS+= -I-
# Uncomment to link against dmalloc
#LDADD+= -L/usr/local/lib -ldmalloc
#CFLAGS+= -I/usr/local/include -DUSE_DMALLOC
#WARNS=6
LDADD+= -L/usr/local/lib -ldmalloc
CFLAGS+= -I/usr/local/include -DUSE_DMALLOC
WARNS=6
test: libarchive_test
./libarchive_test -k
# Build libarchive_test and run it.
check test: libarchive_test ${TESTFILES}
./libarchive_test
.for f in ${TESTFILES}
${f}: ${f}.uu
uudecode -p ${.CURDIR}/${f}.uu >${f}
.endfor
INCS=archive.h list.h
# Build archive.h, but in our .OBJDIR, not libarchive's
# This keeps libarchive_test and libarchive builds completely separate.
archive.h: ${LA_SRCDIR}/archive.h.in ${LA_SRCDIR}/Makefile
cd ${LA_SRCDIR} && unset MAKEOBJDIRPREFIX && MAKEOBJDIR=${.OBJDIR} make archive.h
# list.h is just a list of all tests, as indicated by DEFINE_TEST macro lines
list.h: ${TESTS} Makefile
(cd ${.CURDIR}; cat ${TESTS}) | grep DEFINE_TEST > list.h
clean:
rm -f *.out
rm -f *.o
rm -f *.core
rm -f *~
rm -f list.h
CLEANFILES += *.out *.o *.core *~ list.h archive.h ${TESTFILES}
cleantest:
-chmod -R +w /tmp/libarchive_test.*
rm -rf /tmp/libarchive_test.*

View File

@ -32,7 +32,11 @@ Each test function can rely on the following:
* The test function should use assert(), assertA() and similar macros
defined in test.h. If you need to add new macros of this form, feel
free to do so.
free to do so. The current macro set includes assertEqualInt() and
assertEqualString() that print out additional detail about their
arguments if the assertion does fail. 'A' versions also accept
a struct archive * and display any error message from there on
failure.
* You are encouraged to document each assertion with a failure() call
just before the assert. The failure() function is a printf-like
@ -43,7 +47,10 @@ Each test function can rely on the following:
assert(strcmp(buff1, buff2) == 0);
* Tests are encouraged to be economical with their memory and disk usage,
though this is not essential.
though this is not essential. The test is occasionally run under
a memory debugger to try to locate memory leaks in the library;
as a result, tests should be careful to release any memory they
allocate.
* Disable tests on specific platforms as necessary. Please don't
use config.h to adjust feature requirements, as I want the tests
@ -53,3 +60,4 @@ Each test function can rely on the following:
#if !defined(__PLATFORM) && !defined(__Platform2__)
assert(xxxx)
#endif

View File

@ -23,6 +23,17 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* This same file is used pretty much verbatim for all test harnesses.
*
* The next line is used to define various environment variables, etc.
*
* The tar and cpio test harnesses are identical except for this line;
* the libarchive test harness omits some code that is needed only for
* testing standalone executables.
*/
#define PROGRAM "LIBARCHIVE"
/*
* Various utility routines useful for test programs.
* Each test program is linked against this file.
@ -34,6 +45,18 @@
#include "test.h"
__FBSDID("$FreeBSD$");
/*
* "list.h" is simply created by "grep DEFINE_TEST"; it has
* a line like
* DEFINE_TEST(test_function)
* for each test.
* Include it here with a suitable DEFINE_TEST to declare all of the
* test functions.
*/
#undef DEFINE_TEST
#define DEFINE_TEST(name) void name(void);
#include "list.h"
/* Interix doesn't define these in a standard header. */
#if __INTERIX__
extern char *optarg;
@ -48,6 +71,8 @@ static int quiet_flag = 0;
static int failures = 0;
/* Cumulative count of skipped component tests. */
static int skips = 0;
/* Cumulative count of assertions. */
static int assertions = 0;
/*
* My own implementation of the standard assert() macro emits the
@ -57,12 +82,10 @@ static int skips = 0;
* Emacs. ;-)
*
* It also supports a few special features specifically to simplify
* libarchive test harnesses:
* test harnesses:
* failure(fmt, args) -- Stores a text string that gets
* printed if the following assertion fails, good for
* explaining subtle tests.
* assertA(a, cond) -- If the test fails, also prints out any error
* message stored in archive object 'a'.
*/
static char msg[4096];
@ -76,12 +99,13 @@ static struct line {
int count;
} failed_lines[1000];
/* Count this failure; return the number of previous failures. */
/*
* Count this failure; return the number of previous failures.
*/
static int
previous_failures(const char *filename, int line)
{
int i;
unsigned int i;
int count;
if (failed_filename == NULL || strcmp(failed_filename, filename) != 0)
@ -100,24 +124,30 @@ previous_failures(const char *filename, int line)
return (0);
}
}
return (0);
}
/* Inform user that we're skipping a test. */
static const char *skipped_filename;
static int skipped_line;
void skipping_setup(const char *filename, int line)
/*
* Copy arguments into file-local variables.
*/
static const char *test_filename;
static int test_line;
static void *test_extra;
void test_setup(const char *filename, int line)
{
skipped_filename = filename;
skipped_line = line;
test_filename = filename;
test_line = line;
}
/*
* Inform user that we're skipping a test.
*/
void
test_skipping(const char *fmt, ...)
{
int i;
int line = skipped_line;
va_list ap;
if (previous_failures(skipped_filename, skipped_line))
if (previous_failures(test_filename, test_line))
return;
va_start(ap, fmt);
@ -130,29 +160,30 @@ test_skipping(const char *fmt, ...)
/* Common handling of failed tests. */
static void
test_failed(struct archive *a, int line)
report_failure(void *extra)
{
int i;
failures ++;
if (msg[0] != '\0') {
fprintf(stderr, " Description: %s\n", msg);
msg[0] = '\0';
}
if (a != NULL) {
fprintf(stderr, " archive error: %s\n", archive_error_string(a));
if (extra != NULL) {
fprintf(stderr, " archive error: %s\n", archive_error_string((struct archive *)extra));
}
if (dump_on_failure) {
fprintf(stderr, " *** forcing core dump so failure can be debugged ***\n");
fprintf(stderr,
" *** forcing core dump so failure can be debugged ***\n");
*(char *)(NULL) = 0;
exit(1);
}
}
/* Summarize repeated failures in the just-completed test file. */
int
/*
* Summarize repeated failures in the just-completed test file.
* The reports above suppress multiple failures from the same source
* line; this reports on any tests that did fail multiple times.
*/
static int
summarize_comparator(const void *a0, const void *b0)
{
const struct line *a = a0, *b = b0;
@ -165,10 +196,10 @@ summarize_comparator(const void *a0, const void *b0)
return (a->line - b->line);
}
void
summarize(const char *filename)
static void
summarize(void)
{
int i;
unsigned int i;
qsort(failed_lines, sizeof(failed_lines)/sizeof(failed_lines[0]),
sizeof(failed_lines[0]), summarize_comparator);
@ -196,35 +227,39 @@ failure(const char *fmt, ...)
/* Generic assert() just displays the failed condition. */
void
test_assert(const char *file, int line, int value, const char *condition, struct archive *a)
test_assert(const char *file, int line, int value, const char *condition, void *extra)
{
++assertions;
if (value) {
msg[0] = '\0';
return;
}
failures ++;
if (previous_failures(file, line))
return;
fprintf(stderr, "%s:%d: Assertion failed\n", file, line);
fprintf(stderr, " Condition: %s\n", condition);
test_failed(a, line);
report_failure(extra);
}
/* assertEqualInt() displays the values of the two integers. */
void
test_assert_equal_int(const char *file, int line,
int v1, const char *e1, int v2, const char *e2, struct archive *a)
int v1, const char *e1, int v2, const char *e2, void *extra)
{
++assertions;
if (v1 == v2) {
msg[0] = '\0';
return;
}
failures ++;
if (previous_failures(file, line))
return;
fprintf(stderr, "%s:%d: Assertion failed: Ints not equal\n",
file, line);
fprintf(stderr, " %s=%d\n", e1, v1);
fprintf(stderr, " %s=%d\n", e2, v2);
test_failed(a, line);
report_failure(extra);
}
/* assertEqualString() displays the values of the two strings. */
@ -232,8 +267,9 @@ void
test_assert_equal_string(const char *file, int line,
const char *v1, const char *e1,
const char *v2, const char *e2,
struct archive *a)
void *extra)
{
++assertions;
if (v1 == NULL || v2 == NULL) {
if (v1 == v2) {
msg[0] = '\0';
@ -243,13 +279,14 @@ test_assert_equal_string(const char *file, int line,
msg[0] = '\0';
return;
}
failures ++;
if (previous_failures(file, line))
return;
fprintf(stderr, "%s:%d: Assertion failed: Strings not equal\n",
file, line);
fprintf(stderr, " %s = \"%s\"\n", e1, v1);
fprintf(stderr, " %s = \"%s\"\n", e2, v2);
test_failed(a, line);
report_failure(extra);
}
/* assertEqualWString() displays the values of the two strings. */
@ -257,26 +294,222 @@ void
test_assert_equal_wstring(const char *file, int line,
const wchar_t *v1, const char *e1,
const wchar_t *v2, const char *e2,
struct archive *a)
void *extra)
{
++assertions;
if (wcscmp(v1, v2) == 0) {
msg[0] = '\0';
return;
}
failures ++;
if (previous_failures(file, line))
return;
fprintf(stderr, "%s:%d: Assertion failed: Unicode strings not equal\n",
file, line);
fwprintf(stderr, L" %s = \"%ls\"\n", e1, v1);
fwprintf(stderr, L" %s = \"%ls\"\n", e2, v2);
test_failed(a, line);
report_failure(extra);
}
/*
* Pretty standard hexdump routine. As a bonus, if ref != NULL, then
* any bytes in p that differ from ref will be highlighted with '_'
* before and after the hex value.
*/
static void
hexdump(const char *p, const char *ref, size_t l, size_t offset)
{
size_t i, j;
char sep;
for(i=0; i < l; i+=16) {
fprintf(stderr, "%04x", i + offset);
sep = ' ';
for (j = 0; j < 16 && i + j < l; j++) {
if (ref != NULL && p[i + j] != ref[i + j])
sep = '_';
fprintf(stderr, "%c%02x", sep, p[i+j]);
if (ref != NULL && p[i + j] == ref[i + j])
sep = ' ';
}
for (; j < 16; j++) {
fprintf(stderr, "%c ", sep);
sep = ' ';
}
fprintf(stderr, "%c", sep);
for (j=0; j < 16 && i + j < l; j++) {
int c = p[i + j];
if (c >= ' ' && c <= 126)
fprintf(stderr, "%c", c);
else
fprintf(stderr, ".");
}
fprintf(stderr, "\n");
}
}
/* assertEqualMem() displays the values of the two memory blocks. */
/* TODO: For long blocks, hexdump the first bytes that actually differ. */
void
test_assert_equal_mem(const char *file, int line,
const char *v1, const char *e1,
const char *v2, const char *e2,
size_t l, const char *ld, void *extra)
{
++assertions;
if (v1 == NULL || v2 == NULL) {
if (v1 == v2) {
msg[0] = '\0';
return;
}
} else if (memcmp(v1, v2, l) == 0) {
msg[0] = '\0';
return;
}
failures ++;
if (previous_failures(file, line))
return;
fprintf(stderr, "%s:%d: Assertion failed: memory not equal\n",
file, line);
fprintf(stderr, " size %s = %d\n", ld, (int)l);
fprintf(stderr, " Dump of %s\n", e1);
hexdump(v1, v2, l < 32 ? l : 32, 0);
fprintf(stderr, " Dump of %s\n", e2);
hexdump(v2, v1, l < 32 ? l : 32, 0);
fprintf(stderr, "\n");
report_failure(extra);
}
void
test_assert_empty_file(const char *f1fmt, ...)
{
char f1[1024];
struct stat st;
va_list ap;
va_start(ap, f1fmt);
vsprintf(f1, f1fmt, ap);
va_end(ap);
if (stat(f1, &st) != 0) {
fprintf(stderr, "%s:%d: Could not stat: %s\n", test_filename, test_line, f1);
report_failure(NULL);
} else if (st.st_size > 0) {
fprintf(stderr, "%s:%d: File not empty: %s\n", test_filename, test_line, f1);
fprintf(stderr, " File size: %d\n", (int)st.st_size);
report_failure(NULL);
}
}
/* assertEqualFile() asserts that two files have the same contents. */
/* TODO: hexdump the first bytes that actually differ. */
void
test_assert_equal_file(const char *f1, const char *f2pattern, ...)
{
char f2[1024];
va_list ap;
char buff1[1024];
char buff2[1024];
int fd1, fd2;
int n1, n2;
va_start(ap, f2pattern);
vsprintf(f2, f2pattern, ap);
va_end(ap);
fd1 = open(f1, O_RDONLY);
fd2 = open(f2, O_RDONLY);
for (;;) {
n1 = read(fd1, buff1, sizeof(buff1));
n2 = read(fd2, buff2, sizeof(buff2));
if (n1 != n2)
break;
if (n1 == 0 && n2 == 0)
return;
if (memcmp(buff1, buff2, n1) != 0)
break;
}
fprintf(stderr, "%s:%d: Files are not identical\n", test_filename, test_line);
fprintf(stderr, " file1=\"%s\"\n", f1);
fprintf(stderr, " file2=\"%s\"\n", f2);
report_failure(test_extra);
}
/*
* Call standard system() call, but build up the command line using
* sprintf() conventions.
*/
int
systemf(const char *fmt, ...)
{
char buff[8192];
va_list ap;
int r;
va_start(ap, fmt);
vsprintf(buff, fmt, ap);
r = system(buff);
va_end(ap);
return (r);
}
/*
* Slurp a file into memory for ease of comparison and testing.
* Returns size of file in 'sizep' if non-NULL, null-terminates
* data in memory for ease of use.
*/
char *
slurpfile(size_t * sizep, const char *fmt, ...)
{
char filename[8192];
struct stat st;
va_list ap;
char *p;
ssize_t bytes_read;
int fd;
int r;
va_start(ap, fmt);
vsprintf(filename, fmt, ap);
va_end(ap);
fd = open(filename, O_RDONLY);
if (fd < 0) {
/* Note: No error; non-existent file is okay here. */
return (NULL);
}
r = fstat(fd, &st);
if (r != 0) {
fprintf(stderr, "Can't stat file %s\n", filename);
close(fd);
return (NULL);
}
p = malloc(st.st_size + 1);
if (p == NULL) {
fprintf(stderr, "Can't allocate %ld bytes of memory to read file %s\n", (long int)st.st_size, filename);
close(fd);
return (NULL);
}
bytes_read = read(fd, p, st.st_size);
if (bytes_read < st.st_size) {
fprintf(stderr, "Can't read file %s\n", filename);
close(fd);
free(p);
return (NULL);
}
p[st.st_size] = '\0';
if (sizep != NULL)
*sizep = (size_t)st.st_size;
close(fd);
return (p);
}
/*
* "list.h" is automatically generated; it just has a lot of lines like:
* DEFINE_TEST(function_name)
* The common "test.h" includes it to declare all of the test functions.
* We reuse it here to define a list of all tests to run.
* It's used above to declare all of the test functions.
* We reuse it here to define a list of all tests (functions and names).
*/
#undef DEFINE_TEST
#define DEFINE_TEST(n) { n, #n },
@ -284,6 +517,12 @@ struct { void (*func)(void); const char *name; } tests[] = {
#include "list.h"
};
/*
* Each test is run in a private work dir. Those work dirs
* do have consistent and predictable names, in case a group
* of tests need to collaborate. However, there is no provision
* for requiring that tests run in a certain order.
*/
static int test_run(int i, const char *tmpdir)
{
int failures_before = failures;
@ -307,29 +546,35 @@ static int test_run(int i, const char *tmpdir)
tests[i].name);
exit(1);
}
/* Chdir() to that work directory. */
if (chdir(tests[i].name)) {
fprintf(stderr,
"ERROR: Couldn't chdir to temp dir ``%s''\n",
tests[i].name);
exit(1);
}
/* Run the actual test. */
(*tests[i].func)();
summarize(tests[i].name);
/* Summarize the results of this test. */
summarize();
/* Return appropriate status. */
return (failures == failures_before ? 0 : 1);
}
static void usage(void)
static void usage(const char *program)
{
static const int limit = sizeof(tests) / sizeof(tests[0]);
int i;
printf("Usage: libarchive_test [options] <test> <test> ...\n");
printf("Usage: %s [options] <test> <test> ...\n", program);
printf("Default is to run all tests.\n");
printf("Otherwise, specify the numbers of the tests you wish to run.\n");
printf("Options:\n");
printf(" -k Keep running after failures.\n");
printf(" Default: Core dump after any failure.\n");
printf(" -q Quiet.\n");
printf(" -r <dir> Path to dir containing reference files.\n");
printf(" Default: Current directory.\n");
printf("Available tests:\n");
for (i = 0; i < limit; i++)
printf(" %d: %s\n", i, tests[i].name);
@ -341,19 +586,42 @@ int main(int argc, char **argv)
static const int limit = sizeof(tests) / sizeof(tests[0]);
int i, tests_run = 0, tests_failed = 0, opt;
time_t now;
char *refdir_alloc = NULL;
char *progname, *p;
char tmpdir[256];
char tmpdir_timestamp[256];
while ((opt = getopt(argc, argv, "kq")) != -1) {
/*
* Name of this program, used to build root of our temp directory
* tree.
*/
progname = p = argv[0];
while (*p != '\0') {
if (*p == '/')
progname = p + 1;
++p;
}
/* Get the directory holding test files from environment. */
refdir = getenv(PROGRAM "_TEST_FILES");
/*
* Parse options.
*/
while ((opt = getopt(argc, argv, "kqr:")) != -1) {
switch (opt) {
case 'k':
dump_on_failure = 0;
break;
case 'q':
quiet_flag = 1;
quiet_flag++;
break;
case 'r':
refdir = optarg;
break;
case '?':
default:
usage();
usage(progname);
}
}
argc -= optind;
@ -366,10 +634,10 @@ int main(int argc, char **argv)
*/
now = time(NULL);
for (i = 0; i < 1000; i++) {
strftime(tmpdir, sizeof(tmpdir),
"/tmp/libarchive_test.%Y-%m-%dT%H.%M.%S",
strftime(tmpdir_timestamp, sizeof(tmpdir_timestamp),
"%Y-%m-%dT%H.%M.%S",
localtime(&now));
sprintf(tmpdir + strlen(tmpdir), "-%03d", i);
sprintf(tmpdir, "/tmp/%s.%s-%03d", progname, tmpdir_timestamp, i);
if (mkdir(tmpdir,0755) == 0)
break;
if (errno == EEXIST)
@ -379,11 +647,32 @@ int main(int argc, char **argv)
exit(1);
}
/*
* If the user didn't specify a directory for locating
* reference files, use the current directory for that.
*/
if (refdir == NULL) {
systemf("/bin/pwd > %s/refdir", tmpdir);
refdir = refdir_alloc = slurpfile(NULL, "%s/refdir", tmpdir);
p = refdir + strlen(refdir);
while (p[-1] == '\n') {
--p;
*p = '\0';
}
}
/*
* Banner with basic information.
*/
if (!quiet_flag) {
printf("Running libarchive tests in: %s\n", tmpdir);
printf("Running tests in: %s\n", tmpdir);
printf("Reference files will be read from: %s\n", refdir);
printf("Exercising %s\n", archive_version());
}
/*
* Run some or all of the individual tests.
*/
if (argc == 0) {
/* Default: Run all tests. */
for (i = 0; i < limit; i++) {
@ -396,7 +685,7 @@ int main(int argc, char **argv)
i = atoi(*argv);
if (**argv < '0' || **argv > '9' || i < 0 || i >= limit) {
printf("*** INVALID Test %s\n", *argv);
usage();
usage(progname);
} else {
if (test_run(i, tmpdir))
tests_failed++;
@ -405,10 +694,20 @@ int main(int argc, char **argv)
argv++;
}
}
printf("\n");
printf("%d of %d test groups reported failures\n",
tests_failed, tests_run);
printf(" Total of %d individual tests failed.\n", failures);
printf(" Total of %d individual tests were skipped.\n", skips);
/*
* Report summary statistics.
*/
if (!quiet_flag) {
printf("\n");
printf("%d of %d tests reported failures\n",
tests_failed, tests_run);
printf(" Total of %d assertions checked.\n", assertions);
printf(" Total of %d assertions failed.\n", failures);
printf(" Total of %d assertions skipped.\n", skips);
}
free(refdir_alloc);
return (tests_failed);
}

View File

@ -96,7 +96,7 @@ static ssize_t
memory_read(struct archive *a, void *client_data, const void **buff)
{
struct read_memory_data *mine = (struct read_memory_data *)client_data;
ssize_t size;
size_t size;
(void)a; /* UNUSED */
size = mine->end - mine->buffer;

View File

@ -34,13 +34,13 @@
#define _FILE_OFFSET_BITS 64
#include <archive.h>
#include <archive_entry.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <wchar.h>
#ifdef USE_DMALLOC
@ -68,6 +68,82 @@
#define __FBSDID(a) /* null */
#endif
/*
* Redefine DEFINE_TEST for use in defining the test functions.
*/
#undef DEFINE_TEST
#define DEFINE_TEST(name) void name(void); void name(void)
/* An implementation of the standard assert() macro */
#define assert(e) test_assert(__FILE__, __LINE__, (e), #e, NULL)
/* Assert two integers are the same. Reports value of each one if not. */
#define assertEqualInt(v1,v2) \
test_assert_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
/* Assert two strings are the same. Reports value of each one if not. */
#define assertEqualString(v1,v2) \
test_assert_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
/* As above, but v1 and v2 are wchar_t * */
#define assertEqualWString(v1,v2) \
test_assert_equal_wstring(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
/* As above, but raw blocks of bytes. */
#define assertEqualMem(v1, v2, l) \
test_assert_equal_mem(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (l), #l, NULL)
/* Assert two files are the same; allow printf-style expansion of second name.
* See below for comments about variable arguments here...
*/
#define assertEqualFile \
test_setup(__FILE__, __LINE__);test_assert_equal_file
/* Assert that a file is empty; supports printf-style arguments. */
#define assertEmptyFile \
test_setup(__FILE__, __LINE__);test_assert_empty_file
/*
* This would be simple with C99 variadic macros, but I don't want to
* require that. Instead, I insert a function call before each
* skipping() call to pass the file and line information down. Crude,
* but effective.
*/
#define skipping \
test_setup(__FILE__, __LINE__);test_skipping
/* Function declarations. These are defined in test_utility.c. */
void failure(const char *fmt, ...);
void test_setup(const char *, int);
void test_skipping(const char *fmt, ...);
void test_assert(const char *, int, int, const char *, void *);
void test_assert_empty_file(const char *, ...);
void test_assert_equal_file(const char *, const char *, ...);
void test_assert_equal_int(const char *, int, int, const char *, int, const char *, void *);
void test_assert_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *);
void test_assert_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *);
void test_assert_equal_mem(const char *, int, const char *, const char *, const char *, const char *, size_t, const char *, void *);
/* Like sprintf, then system() */
int systemf(const char * fmt, ...);
/* Suck file into string allocated via malloc(). Call free() when done. */
/* Supports printf-style args: slurpfile(NULL, "%s/myfile", refdir); */
char *slurpfile(size_t *, const char *fmt, ...);
/*
* Global vars
*/
/* Directory holding reference files. */
char *refdir;
/*
* Special interfaces for libarchive test harness.
*/
#include "archive.h"
#include "archive_entry.h"
/* Special customized read-from-memory interface. */
int read_open_memory(struct archive *, void *, size_t, size_t);
/*
* ARCHIVE_VERSION_STAMP first appeared in 1.9 and libarchive 2.2.4.
* We can approximate it for earlier versions, though.
@ -79,61 +155,9 @@
(ARCHIVE_API_VERSION * 1000000 + ARCHIVE_API_FEATURE * 1000)
#endif
/*
* "list.h" is simply created by "grep DEFINE_TEST"; it has
* a line like
* DEFINE_TEST(test_function)
* for each test.
* Include it here with a suitable DEFINE_TEST to declare all of the
* test functions.
*/
#define DEFINE_TEST(name) void name(void);
#include "list.h"
/*
* Redefine DEFINE_TEST for use in defining the test functions.
*/
#undef DEFINE_TEST
#define DEFINE_TEST(name) void name(void)
/* An implementation of the standard assert() macro */
#define assert(e) test_assert(__FILE__, __LINE__, (e), #e, NULL)
/* As above, but reports any archive_error found in variable 'a' */
/* Versions of above that accept an archive argument for additional info. */
#define assertA(e) test_assert(__FILE__, __LINE__, (e), #e, (a))
/* Asserts that two integers are the same. Reports value of each one if not. */
#define assertEqualIntA(a,v1,v2) \
test_assert_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a))
#define assertEqualInt(v1,v2) \
test_assert_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
/* Asserts that two strings are the same. Reports value of each one if not. */
#define assertEqualStringA(a,v1,v2) \
test_assert_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a))
#define assertEqualString(v1,v2) \
test_assert_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
/* As above, but v1 and v2 are wchar_t * */
#define assertEqualWString(v1,v2) \
test_assert_equal_wstring(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
/*
* This would be simple with C99 variadic macros, but I don't want to
* require that. Instead, I insert a function call before each
* skipping() call to pass the file and line information down. Crude,
* but effective.
*/
#define skipping \
skipping_setup(__FILE__, __LINE__);test_skipping
/* Function declarations. These are defined in test_utility.c. */
void failure(const char *fmt, ...);
void skipping_setup(const char *, int);
void test_skipping(const char *fmt, ...);
void test_assert(const char *, int, int, const char *, struct archive *);
void test_assert_equal_int(const char *, int, int, const char *, int, const char *, struct archive *);
void test_assert_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, struct archive *);
void test_assert_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, struct archive *);
/* Special customized read-from-memory interface. */
int read_open_memory(struct archive *, void *, size_t, size_t);
int read_open_memory(struct archive *, void *, size_t, size_t);

View File

@ -0,0 +1,110 @@
/*-
* Copyright (c) 2003-2007 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"
__FBSDID("$FreeBSD$");
/*
* Verify our ability to read sample files created by GNU tar.
* It should be easy to add any new sample files sent in by users
* to this collection of tests.
*/
/* Copy this function for each test file and adjust it accordingly. */
/*
* test_compat_gtar_1.tgz exercises reading long filenames and
* symlink targets stored in the GNU tar format.
*/
static void
test_compat_gtar_1(void)
{
char name[1024];
struct archive_entry *ae;
struct archive *a;
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
sprintf(name, "%s/test_compat_gtar_1.tgz", refdir);
assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240));
/* Read first entry. */
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString(
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890",
archive_entry_pathname(ae));
assertEqualInt(1197179003, archive_entry_mtime(ae));
assertEqualInt(1000, archive_entry_uid(ae));
assertEqualString("tim", archive_entry_uname(ae));
assertEqualInt(1000, archive_entry_gid(ae));
assertEqualString("tim", archive_entry_gname(ae));
assertEqualInt(0100644, archive_entry_mode(ae));
/* Read second entry. */
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString(
"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij"
"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij"
"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij"
"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij",
archive_entry_pathname(ae));
assertEqualString(
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890",
archive_entry_symlink(ae));
assertEqualInt(1197179043, archive_entry_mtime(ae));
assertEqualInt(1000, archive_entry_uid(ae));
assertEqualString("tim", archive_entry_uname(ae));
assertEqualInt(1000, archive_entry_gid(ae));
assertEqualString("tim", archive_entry_gname(ae));
assertEqualInt(0120755, archive_entry_mode(ae));
/* Verify the end-of-archive. */
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
/* Verify that the format detection worked. */
assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_GZIP);
assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_GNUTAR);
assertEqualInt(ARCHIVE_OK, archive_read_close(a));
#if ARCHIVE_API_VERSION > 1
assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
#else
archive_read_finish(a);
#endif
}
DEFINE_TEST(test_compat_gtar)
{
test_compat_gtar_1();
}

View File

@ -0,0 +1,9 @@
begin 644 test_compat_gtar_1.tgz
M'XL(`,N`6T<``^W62PZ",!`&X!YE3@`SI:6Z<R^7\(&*+Q+%>'W+PJB)43=4
MJO^W:1.Z:#KYATG2)!T5]7Y95/N-Z@:UF)ZO7B9"-TPD[%@4%1W=Y\'IV$P.
M1.I0U\VK<^=566Y#7"@LT9FQN1L,.>[=M]\Q5@%JHX0Y-Z;-NSC+]^LM\S[R
M.G?,XC(B+:Q949"B7O/?5+N7Y]Y]CU32U_[OZS_NZ#X/T/][T\/1_\/K;?XQ
M_P4QF<[FY6*YJM9Q[[[]CK$*4!O_CV%G[6?SGS9^_C/&:I]_'6(X_?/Y#P``
4````````````?L\%KFMT6@`H````
`
end

View File

@ -0,0 +1,69 @@
/*-
* Copyright (c) 2003-2007 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"
__FBSDID("$FreeBSD$");
/* Copy this function for each test file and adjust it accordingly. */
static void
test_compat_zip_1(void)
{
char name[1024];
struct archive_entry *ae;
struct archive *a;
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
sprintf(name, "%s/test_compat_zip_1.zip", refdir);
assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240));
/* Read first entry. */
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString("META-INF/MANIFEST.MF", archive_entry_pathname(ae));
/* Read second entry. */
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString("tmp.class", archive_entry_pathname(ae));
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_NONE);
assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ZIP);
assertEqualInt(ARCHIVE_OK, archive_read_close(a));
#if ARCHIVE_API_VERSION > 1
assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
#else
archive_read_finish(a);
#endif
}
DEFINE_TEST(test_compat_zip)
{
test_compat_zip_1();
}

View File

@ -0,0 +1,14 @@
begin 644 test_compat_zip_1.zip
M4$L#!!0`"``(``B$@S<````````````````4````345402U)3D8O34%.249%
M4U0N34;S3<S+3$LM+M$-2RTJSLS/LU(PU#/@Y7+,0Q)Q+$A,SDA5`(H!)<U!
MTLY%J8DEJ2FZ3I56"BF9B4DY^;J&>J9Z!O$&YKI)!H8*&L&E>0J^F<E%^<65
MQ26IN<4*GGG)>IJ\7+Q<`%!+!PAHTY\490```'$```!02P,$%``(``@`"(2#
M-P````````````````D```!T;7`N8VQA<W,[]6_7/@8&!D,&+G8&#G8&3BX&
M1@86'@8V!E9&!F8-S3!&!C:;S+S,$CN@L'-^2BHC@T!68EFB?DYB7KJ^?U)6
M:G()4&%);@&#(@,34"\(,`(AT``@R0[D"8+Y#`RL6ML9F#>"%3```%!+!P@+
M(*8V:````'8```!02P$"%``4``@`"``(A(,W:-.?%&4```!Q````%```````
M````````````````345402U)3D8O34%.249%4U0N34902P$"%``4``@`"``(
MA(,W"R"F-F@```!V````"0````````````````"G````=&UP+F-L87-S4$L%
J!@`````"``(`>0```$8!```7`%!R;T=U87)D+"!V97)S:6]N(#0N,"XQ
`
end

View File

@ -0,0 +1,118 @@
/*-
* Copyright (c) 2003-2007 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"
__FBSDID("$FreeBSD$");
DEFINE_TEST(test_empty_write)
{
char buff[32768];
struct archive_entry *ae;
struct archive *a;
size_t used;
/*
* Exercise a zero-byte write to a gzip-compressed archive.
*/
/* Create a new archive in memory. */
assert((a = archive_write_new()) != NULL);
assertA(0 == archive_write_set_format_ustar(a));
assertA(0 == archive_write_set_compression_gzip(a));
assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used));
/* Write a file to it. */
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, "file");
archive_entry_set_mode(ae, S_IFREG | 0755);
archive_entry_set_size(ae, 0);
assertA(0 == archive_write_header(a, ae));
/* THE TEST: write zero bytes to this entry. */
/* This used to crash. */
assertEqualIntA(a, 0, archive_write_data(a, "", 0));
/* Close out the archive. */
assertA(0 == archive_write_close(a));
#if ARCHIVE_API_VERSION > 1
assertA(0 == archive_write_finish(a));
#else
archive_write_finish(a);
#endif
/*
* Again, with bzip2 compression.
*/
/* Create a new archive in memory. */
assert((a = archive_write_new()) != NULL);
assertA(0 == archive_write_set_format_ustar(a));
assertA(0 == archive_write_set_compression_bzip2(a));
assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used));
/* Write a file to it. */
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, "file");
archive_entry_set_mode(ae, S_IFREG | 0755);
archive_entry_set_size(ae, 0);
assertA(0 == archive_write_header(a, ae));
/* THE TEST: write zero bytes to this entry. */
assertEqualIntA(a, 0, archive_write_data(a, "", 0));
/* Close out the archive. */
assertA(0 == archive_write_close(a));
#if ARCHIVE_API_VERSION > 1
assertA(0 == archive_write_finish(a));
#else
archive_write_finish(a);
#endif
/*
* For good measure, one more time with no compression.
*/
/* Create a new archive in memory. */
assert((a = archive_write_new()) != NULL);
assertA(0 == archive_write_set_format_ustar(a));
assertA(0 == archive_write_set_compression_none(a));
assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used));
/* Write a file to it. */
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, "file");
archive_entry_set_mode(ae, S_IFREG | 0755);
archive_entry_set_size(ae, 0);
assertA(0 == archive_write_header(a, ae));
/* THE TEST: write zero bytes to this entry. */
assertEqualIntA(a, 0, archive_write_data(a, "", 0));
/* Close out the archive. */
assertA(0 == archive_write_close(a));
#if ARCHIVE_API_VERSION > 1
assertA(0 == archive_write_finish(a));
#else
archive_write_finish(a);
#endif
}

View File

@ -0,0 +1,48 @@
/*-
* Copyright (c) 2003-2007 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"
__FBSDID("$FreeBSD$");
DEFINE_TEST(test_entry_strmode)
{
struct archive_entry *entry;
assert((entry = archive_entry_new()) != NULL);
archive_entry_set_mode(entry, S_IFREG | 0642);
assertEqualString(archive_entry_strmode(entry), "-rw-r---w- ");
archive_entry_set_mode(entry, S_IFBLK | 03642);
assertEqualString(archive_entry_strmode(entry), "brw-r-S-wT ");
archive_entry_set_mode(entry, S_IFCHR | 05777);
assertEqualString(archive_entry_strmode(entry), "crwsrwxrwt ");
archive_entry_set_mode(entry, S_IFLNK | 04000);
assertEqualString(archive_entry_strmode(entry), "l--S------ ");
/* Release the experimental entry. */
archive_entry_free(entry);
}

View File

@ -54,7 +54,7 @@ DEFINE_TEST(test_read_format_cpio_odc)
assertA(0 == archive_read_support_compression_all(a));
assertA(0 == archive_read_support_format_all(a));
assertA(0 == archive_read_open_memory(a, archive, sizeof(archive)));
assertA(0 == archive_read_next_header(a, &ae));
assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
assertA(archive_compression(a) == ARCHIVE_COMPRESSION_NONE);
assertA(archive_format(a) == ARCHIVE_FORMAT_CPIO_POSIX);
assert(0 == archive_read_close(a));

View File

@ -29,7 +29,7 @@ __FBSDID("$FreeBSD$");
struct contents {
off_t o;
size_t s;
char *d;
const char *d;
};
struct contents archive_contents_sparse[] = {
@ -171,623 +171,6 @@ struct archive_contents {
{ NULL, NULL }
};
/* Old GNU tar sparse format, as created by gtar 1.13 */
static unsigned char archive_old_gtar_1_13[] = {
31,139,8,0,30,'%',193,'F',0,3,237,215,'K','n',219,'H',20,133,'a',246,'N',
180,129,6,170,'n',189,22,210,'+',208,' ',131,12,146,14,',','g',255,'}',201,
192,142,17,29,'(','A',159,24,'l',160,255,207,3,219,'e',193,186,'$',127,241,
'q',251,'r','}',186,'}',216,222,'U',169,165,204,222,183,'R','J',']',163,188,
253,190,139,252,'u',171,'e',206,18,17,189,205,'m','_',')',177,']',254,'z',
223,177,190,249,'z','{',190,'>',']','.',219,243,199,'O',15,'_',247,179,191,
255,'k',251,'.','h',179,231,'>','z',221,'#',175,'?',231,'^',10,177,'^',219,
':',188,172,239,'K',15,223,160,246,'o',175,250,253,211,'_',127,255,191,196,
255,8,253,0,231,185,29,215,255,'x',215,247,'x','x',253,175,'=',218,221,245,
'?','j',31,'\\',255,31,'\\',255,'[','o','j','}','E',233,'?',174,255,'Q',202,
'X','u',212,213,212,'M',194,'~',167,213,'J',31,226,191,197,'\\','e',138,245,
22,163,'/',181,158,27,161,182,162,'G',12,181,21,'}',214,170,182,'"','G',29,
'w','[',177,175,143,'Y',213,156,'3','c','Q','s',206,209,170,154,'s',213,':',
139,'Z',207,157,'-',230,220,227,157,'b',206,154,'{','-',196,156,185,15,218,
20,'s',214,',','=',196,156,'5',223,'s',138,'9','k',180,213,196,156,'5','V',
30,'O',177,190,'G',161,230,'l','+',214,'}',21,175,199,191,246,'V',155,154,
183,207,181,212,188,'#','f','S',243,142,'c',171,239,215,'g','4','U','w',157,
'3','T',221,'G',196,'j',191,230,'f',23,'1','g',228,';','w','1','g',148,172,
'H',204,25,181,198,16,'s','F','~','F','T',191,217,196,'R',253,230,185,'j',
170,'~',143,143,147,154,'3',15,'O','U','s',246,220,0,'5','g',238,132,'P',
's',246,'5',167,154,'s',180,161,250,141,177,218,'}',191,223,143,127,30,205,
'P',29,31,31,127,'5',239,218,191,212,250,'<','6',227,199,245,150,19,'7','1',
'o','+','3',255,145,'X',175,'Q','U',199,'-',247,210,'}',199,251,233,168,'N',
213,239,'q',154,18,'s',182,204,189,171,'9','s',247,21,'5','g',198,219,213,
156,'=',207,130,'j',206,145,225,169,'9',247,'U','5','g','^',247,'T',191,'/',
167,211,251,245,181,134,154,'3',15,'s','U','s',230,'^',27,15,142,127,223,
247,136,152,'7','?','<','U','u',220,'3','z',213,'q',207,15,180,234,248,'8',
253,139,'y','{',134,'7',197,188,'=','s',12,177,'_',243,206,' ',239,'"',196,
'z',207,'3',134,154,'3','?',133,170,223,'>',242,'D',172,230,28,'#','T',191,
199,'e','J',205,'9','3','/','5','g','~','l',154,154,'s','e','0','b',206,177,
167,'\'',230,28,185,'G','U',191,251,177,'W',253,142,'<',209,171,'~',143,203,
233,131,227,'?',242,196,'t',127,215,176,175,175,'P',247,5,'#','s','Q',247,
5,'#',195,'T',247,5,'#',15,180,234,'8','O',218,']','u',156,135,161,169,142,
143,203,191,154,'s',238,'W',0,181,190,127,137,245,227,'f',232,205,'z',145,
'7','F',248,'%','<',191,195,'A','?','p',208,15,28,244,3,7,253,192,'A','?',
'p',184,253,208,31,28,244,3,7,253,192,'A','?','p',208,15,28,244,3,7,253,192,
193,243,'?',206,'D','?','p',208,15,28,244,3,7,253,192,'A','?','p',208,15,
28,'<',255,227,'L',244,3,7,253,192,'A','?','p',208,15,28,244,3,7,253,192,
193,243,'?',206,'D','?','p',208,15,28,244,3,7,253,192,'A','?','p',208,15,
28,'<',255,227,'L',244,3,7,253,192,'A','?','p',208,15,28,244,3,7,253,192,
193,243,'?',206,'D','?','p',208,15,28,244,3,7,253,192,'A','?','p',208,15,
28,'<',255,227,'L',244,3,7,253,192,'A','?','p',208,15,28,244,3,7,253,192,
193,243,'?',206,'D','?','p',208,15,28,244,3,7,253,192,'A','?','p',208,15,
28,'<',255,227,'L',244,3,7,253,192,'A','?','p',208,15,28,244,3,7,253,192,
193,243,'?',206,'D','?','p',208,15,28,244,3,7,253,192,'A','?','p',208,15,
28,'<',255,227,'L',244,3,7,253,192,'A','?','p',208,15,28,244,3,7,253,192,
193,243,'?',206,'D','?','p',208,15,28,244,227,249,252,247,231,'?','o','_',
174,'O',183,15,239,247,30,165,150,'2','{',223,'J',')','u',141,242,246,251,
139,173,150,'9','K','D',244,'6',243,245,'5',127,218,'.',229,253,'F',250,238,
235,237,249,250,'t',185,'l',207,31,'?','=','|',221,207,254,14,0,0,0,0,0,0,
0,255,'1',255,0,178,'s',140,'2',0,240,0,0};
/* Old GNU tar sparse format, as created by gtar 1.17 */
static unsigned char archive_old_gtar_1_17[] = {
31,139,8,0,30,'%',193,'F',0,3,237,215,']','r',19,'G',20,134,'a','e','\'',
218,'@',170,186,'O',255,'-','$','+',208,5,23,'\\','@','(',203,236,'?','g',
134,216,'8',232,139,160,248,'P','M',170,242,'>',20,'%',211,'6',214,153,158,
'W','#',205,245,211,229,233,250,238,244,'P','%',205,222,183,199,186,'F','y',
251,184,137,252,'{',170,'e',206,18,17,189,205,'S','~','w',197,'<',157,255,
'x',236,'X','_','|',190,'>','_',158,206,231,211,243,251,15,'w',127,238,'{',
223,255,'i',219,22,180,217,235,182,11,127,239,200,235,215,185,'K','!',214,
'k',255,242,239,151,245,253,235,'{','O',240,250,31,'~',185,203,175,255,149,
248,31,161,159,'c',']',247,235,127,'<',244,'9',238,'^',255,'k',143,'V',234,
'?',175,255,17,'5',127,156,235,255,191,'^',255,'[',235,'M',173,175,'(',253,
219,245,223,'J',25,171,142,186,182,'m','V',207,158,251,223,135,248,'m','1',
'W',153,'b',189,197,232,'K',173,231,'A',168,163,232,17,'C',29,'E',159,181,
170,163,200,'Q',199,205,'Q','l',235,'c','V','5',231,172,'}',168,'9',231,'h',
'U',205,185,'j',157,'E',173,231,'f',139,'9',243,'a','N','1','g',205,']',11,
'1','g',238,'A',155,'b',206,154,165,135,152,179,230,'s','N','1','g',141,182,
154,152,179,198,202,243,')',214,183,'(',212,156,'m',197,186,173,226,245,252,
215,222,'j','S',243,246,185,150,154,'w',196,'l','j',222,177,31,245,237,250,
140,166,234,174,'s',134,170,'{',143,'X',237,'k',30,'v',17,'s','F','>','s',
23,'s','F',201,138,196,156,'Q','k',12,'1','g',228,'k','D',245,155,'M',',',
213,'o','^',171,166,234,'w',127,'9',169,'9',243,244,'T','5','g',207,3,'P',
's',230,'&',132,154,179,175,'9',213,156,163,13,213,'o',140,213,'n',251,253,
'z',254,243,'l',134,234,'x',127,249,171,'y',215,246,'G',173,207,253,'0',190,
']','o','9','q',19,243,182,'2',243,23,137,245,26,'U','u',220,'r',151,'n',
';',222,'.','G','u',170,'~',247,203,148,152,179,'e',238,']',205,153,219,'W',
212,156,25,'o','W','s',246,188,10,170,'9','G',134,167,230,220,'V',213,156,
249,190,167,250,'}',185,156,222,174,175,'5',212,156,'y',154,171,154,'3','w',
'm',220,'9',255,'}',219,17,'1','o',190,'x',170,234,184,'g',244,170,227,158,
'/','h',213,241,'~',249,23,243,246,12,'o',138,'y','{',230,24,'b','_',243,
147,'A','~',138,16,235,'=',175,24,'j',206,'|',21,170,'~',251,200,11,177,154,
's',140,'P',253,238,'o','S','j',206,153,'y',169,'9',243,'e',211,212,156,'+',
131,17,'s',142,'-','=','1',231,200,29,'U',253,'n',231,'^',245,';',242,'B',
175,250,221,223,'N',239,156,255,145,23,166,219,'O',13,219,250,10,245,185,
'`','d','.',234,'s',193,200,'0',213,231,130,145,'\'','Z','u',156,23,237,174,
':',206,211,208,'T',199,251,219,191,154,'s','n',239,0,'j','}',251,'#',214,
247,15,'C','o',214,139,252,'`',132,31,194,253,27,28,244,3,7,253,192,'A','?',
'p',208,15,28,244,3,135,219,15,253,193,'A','?','p',208,15,28,244,3,7,253,
192,'A','?','p',208,15,28,220,255,227,'H',244,3,7,253,192,'A','?','p',208,
15,28,244,3,7,253,192,193,253,'?',142,'D','?','p',208,15,28,244,3,7,253,192,
'A','?','p',208,15,28,220,255,227,'H',244,3,7,253,192,'A','?','p',208,15,
28,244,3,7,253,192,193,253,'?',142,'D','?','p',208,15,28,244,3,7,253,192,
'A','?','p',208,15,28,220,255,227,'H',244,3,7,253,192,'A','?','p',208,15,
28,244,3,7,253,192,193,253,'?',142,'D','?','p',208,15,28,244,3,7,253,192,
'A','?','p',208,15,28,220,255,227,'H',244,3,7,253,192,'A','?','p',208,15,
28,244,3,7,253,192,193,253,'?',142,'D','?','p',208,15,28,244,3,7,253,192,
'A','?','p',208,15,28,220,255,227,'H',244,3,7,253,192,'A','?','p',208,15,
28,244,3,7,253,192,193,253,'?',142,'D','?','p',208,15,28,244,3,7,253,192,
'A','?','p',208,15,28,220,255,227,'H',244,3,7,253,192,'A','?',158,143,127,
'~',252,253,250,233,242,'t','}',247,184,231,'(','i',246,190,'=',214,'5',202,
219,199,23,167,'Z',230,',',17,209,219,'<',149,'Z','#',234,233,'\\',30,'7',
210,'W',159,175,207,151,167,243,249,244,252,254,195,221,159,251,222,247,1,
0,0,0,0,0,0,0,248,15,249,11,162,'$',218,227,0,240,0,0};
#if ARCHIVE_VERSION_STAMP >= 1009000
/* libarchive < 1.9 does not support this. */
/* GNU tar "posix" sparse format 0.0, as created by gtar 1.17 */
static unsigned char archive_0_0_gtar_1_17[] = {
31,139,8,0,31,'%',193,'F',0,3,237,217,207,'n',218,'X',20,199,'q',214,'<',
5,'/','0',228,222,'s','}',255,'x',193,'z',186,26,'u',211,7,240,164,174,20,
205,'$',169,'0',145,'2',243,244,'5','%',205,144,200,193,'p',14,141,203,232,
251,217,'P','A',14,'8','9',191,'[',253,',',150,'W',31,155,199,15,'m',243,
185,']','w',203,232,156,148,171,238,'k',179,238,218,217,249,184,'^',170,170,
237,163,207,209,237,'?','~','W','9',153,'y',151,146,19,145,'*',228,153,243,
161,'J','2','[','<',158,241,26,222,244,208,'m',154,'u',127,')',214,247,'y',
250,']',158,31,'/',132,228,197,239,127,'|','Z',238,'v',190,236,'n',254,'m',
'W',193,'W','1','K',153,'K',218,127,233,238,225,246,207,191,239,175,255,234,
'V','a','.','e',255,149,251,'/','_',186,'v',179,170,'{','!',205,'_',190,225,
'v',234,159,'M',219,173,162,151,185,212,3,'c',190,31,'+','Y','N',158,'{',
190,202,'8','8',231,230,226,22,205,230,230,182,']','y','_',178,'K',193,'e',
191,'}',238,250,229,'s','n','>',245,6,166,'u',246,195,'>','`',228,252,203,
246,184,252,'w',254,'S',127,254,'}',14,'a',182,'x',151,'C',244,227,252,247,
177,'8',248,'s','c',175,'_',232,249,183,'j',166,190,0,'\\','4',242,'3',173,
229,'[',253,'O',206,247,25,135,255,255,247,193,247,157,239,'U',255,139,'1',
210,255,222,195,203,'*',247,189,255,213,245,'n','/',3,149,'l','W',0,235,250,
151,'h',128,178,157,'s',229,244,230,216,207,229,170,':','y',174,234,231,'R',
'q','\'',207,197,237,156,'?',253,239,146,250,185,24,'O',255,187,148,']',2,
'O',159,'S',238,175,30,223,'_','p','C','{','w',227,11,28,30,244,227,27,28,
30,148,241,21,14,15,134,241,29,14,15,'V',227,'K',28,30,'L',227,'[','|','c',
'p','|',141,195,131,'Y',187,199,162,221,'c',173,220,163,'8',229,30,197,'+',
247,'(',162,220,163,'T',202,'=','J',165,220,163,'D',229,30,'%',')',247,'(',
'Y',187,199,162,221,'c',173,220,'c','p',202,'=',6,'Q',238,'1',136,'r',143,
'!','(',247,24,'*',229,30,'C','T',238,'1','$',229,30,'C',214,238,177,'(',
247,248,'t',28,'O',191,212,202,')',247,'X',29,209,'o',134,7,143,'(','8',195,
131,'G','4',156,225,193,'#','*',206,240,224,17,29,'g','x',240,136,146,'3',
'<','x','D',203,'y','c','P',187,'G','m',207,137,218,158,19,181,'=','\'','j',
'{','N',212,246,156,168,237,'9','Q',219,'s',162,182,231,'D','m',207,137,218,
158,19,181,'=','\'','i','{','N',210,246,156,164,237,'9','I',219,'s',146,182,
231,'$','m',207,'I',218,158,147,180,'=','\'','i','{','N',210,246,156,172,
237,'9','Y',219,'s',178,182,231,'d','m',207,201,218,158,147,181,'=','\'',
'k','{','N',214,246,156,172,237,'9','E',219,'s',138,182,231,20,'m',207,')',
218,158,'S',180,'=',167,'h','{','N',209,246,156,162,237,'9','E',219,'s',138,
182,231,20,'m',207,169,181,'=',167,214,246,156,'Z',219,'s','j','m',207,169,
181,'=',167,214,246,156,'Z',219,'s','j','m',207,169,'G','z',142,175,3,'_',
174,255,'_',236,150,'{',198,'/','{',6,28,252,254,199,'W',18,156,127,245,253,
191,'8','I','|',255,127,9,248,254,22,22,228,7,22,228,7,22,228,7,22,228,7,
22,228,7,22,214,252,144,'?','X',144,31,'X',144,31,'X',144,31,'X',144,31,'X',
144,31,'X',144,31,'X','p',255,143,')',145,31,'X',144,31,'X',144,31,'X',144,
31,'X',144,31,'X',144,31,'X','p',255,143,')',145,31,'X',144,31,'X',144,31,
'X',144,31,'X',144,31,'X',144,31,'X','p',255,143,')',145,31,'X',144,31,'X',
144,31,'X',144,31,'X',144,31,'X',144,31,'X','p',255,143,')',145,31,'X',144,
31,'X',144,31,'X',144,31,'X',144,31,'X',144,31,'X','p',255,143,')',145,31,
'X',144,31,'X',144,31,'X',144,31,'X',144,31,'X',144,31,'X','p',255,143,')',
145,31,'X',144,31,'X',144,31,'X',144,31,'X',144,31,'X',144,31,'X','p',255,
143,')',145,31,'X',144,31,'X',144,31,'X',144,31,'X',144,31,'X',144,31,'X',
'p',255,143,')',145,31,'X',144,31,'X',144,31,'X',144,31,'X',144,31,'X',144,
31,'X','p',255,143,')',145,31,'X',144,31,'X',144,31,'X',144,31,'X',144,31,
'X',144,31,'X','p',255,143,')',145,31,'X',144,31,'X',144,31,'X',144,31,'X',
144,31,'X',144,31,'X','p',255,143,')',145,31,'X',144,31,'X',144,31,155,229,
213,199,230,241,'C',219,'|','n',215,221,'2',':','\'',229,234,238,254,238,
183,238,'k',179,238,218,'3','}',134,235,165,170,218,'>',250,28,221,254,227,
'N',255,'o',239,'R','r','"','R',133,'<','s',190,146,232,'g',139,199,'3','}',
254,'A',15,221,166,'Y',247,151,'b','}',159,167,'_',229,249,241,'B',136,'[',
'4',155,155,219,'v',229,'}',201,'.',5,151,221,188,127,238,250,245,'s','S',
'_','\'','~',142,179,31,246,1,163,231,223,237,159,255,212,159,127,137,210,
159,255,'w','9','D','?',206,127,31,248,131,'?','7',246,250,133,158,127,0,
0,0,0,0,0,0,0,0,0,0,0,0,192,'e',250,6,'X',180,13,'8',0,24,1,0};
#endif
#if ARCHIVE_VERSION_STAMP >= 1009000
/* libarchive < 1.9 does not support this. */
/* GNU tar "posix" sparse format 0.1, as created by gtar 1.17 */
static unsigned char archive_0_1_gtar_1_17[] = {
31,139,8,0,31,'%',193,'F',0,3,237,215,205,'n',26,'W',24,135,'q',214,'\\',
5,23,224,194,249,'>','3',11,182,'m','V','U',164,170,23,'0','u','f','a','%',
'v',',',198,150,172,'^','}',135,15,'\'',127,187,9,'T','z',137,167,'D',207,
'o',195,4,'l','^','0',207,'!',231,',','W',239,187,167,'w','}',247,161,223,
12,203,236,'\\',244,171,225,190,219,12,253,236,'|',220,168,164,180,189,245,
'5',';',189,221,9,'9',204,188,'+',197,133,16,'R',172,'3',231,'c',202,'u',
182,'x',':',227,'k',248,174,199,225,161,219,140,'/',197,250,'<',135,247,242,
229,246,'B',132,186,248,237,247,'?',151,251,207,'|','9',220,252,221,175,163,
31,255,250,161,153,135,162,15,221,'=',222,254,245,233,243,245,199,'a',29,
'_','?',210,221,246,235,253,245,'<','{','}',228,182,187,'_',183,163,'X',174,
178,15,'W','~',188,'l','j',216,']',31,134,'\\',185,'y','p',139,238,225,'f',
'|',10,239,155,234,'J','t',213,'o',239,187,'~','y',159,155,'O',253,151,250,
'9','-','W',227,231,245,199,238,227,250,245,230,'S',255,'C',190,2,'N',172,
255,176,']','.','_',215,127,25,215,127,246,169,204,22,'o',178,136,158,215,
255,152,219,209,159,';',245,248,133,174,127,171,'n',234,23,128,139,'F','?',
211,'Z','~','o',255,23,206,'7',227,212,247,127,241,178,255,'K','n',187,255,
203,'1',179,255,'{',11,161,249,215,254,175,'m','w',239,'`',220,133,213,'o',
'o',0,219,246,245,'C','_','w',128,'a',238,'C','[',254,227,'&','0','l',175,
']',179,223,16,142,215,'5',165,221,'u',26,175,'K',227,'v',215,'y','{',237,
247,191,'[',198,235,156,247,191,219,236,255,206,251,'k','y',254,'V',158,223,
';',25,224,189,'L',240,'A','F',248,'(','3','|',146,'!',190,200,20,'_',244,
'm','T',157,211,232,156,'V',230,4,'\'','s',130,151,'9','!',200,156,144,'d',
'N','H','2','\'','d',253,'{',21,153,19,170,206,'i','t','N','+','s',162,147,
'9','1',200,156,24,'d','N',140,186,'9','O',250,193,'d',153,19,139,204,137,
'U',231,'4','2',231,240,'v',220,225,31,'2','\'',233,231,159,'4',128,244,162,
0,'M',' ','i',3,'I','#','H','Z','A',210,12,146,'v',144,181,131,172,29,'d',
237,' ','k',7,'Y',';',200,218,'A',214,14,178,'v',144,181,131,172,29,20,237,
160,'h',7,'E',';','(',218,'A',209,14,138,'v','P',180,131,162,29,20,237,160,
'h',7,'U',';',168,218,'A',213,14,170,'v','P',181,131,170,29,'T',237,160,'j',
7,'U',';','h',180,131,'F',';','h',180,131,'F',';','h',180,131,'F',';','h',
180,131,230,197,151,193,139,'o',3,237,160,209,14,'Z',237,160,213,14,'Z',237,
160,213,14,'Z',237,160,213,14,'Z',237,160,213,14,218,231,14,'|',27,255,231,
231,219,'c',231,191,'s','m',1,142,254,255,239,'S',136,206,191,'>',255,133,
228,'9',255,']',2,246,239,176,160,31,'X',208,15,',',232,7,22,244,3,11,250,
129,133,181,31,250,131,5,253,192,130,'~','`','A','?',176,160,31,'X',208,15,
',',232,7,22,156,255,'1','%',250,129,5,253,192,130,'~','`','A','?',176,160,
31,'X',208,15,',','8',255,'c','J',244,3,11,250,129,5,253,192,130,'~','`',
'A','?',176,160,31,'X','p',254,199,148,232,7,22,244,3,11,250,129,5,253,192,
130,'~','`','A','?',176,224,252,143,')',209,15,',',232,7,22,244,3,11,250,
129,5,253,192,130,'~','`',193,249,31,'S',162,31,'X',208,15,',',232,7,22,244,
3,11,250,129,5,253,192,130,243,'?',166,'D','?',176,160,31,'X',208,15,',',
232,7,22,244,3,11,250,129,5,231,127,'L',137,'~','`','A','?',176,160,31,'X',
208,15,',',232,7,22,244,3,11,206,255,152,18,253,192,130,'~','`','A','?',176,
160,31,'X',208,15,',',232,7,22,156,255,'1','%',250,129,5,253,192,130,'~',
'`','A','?',176,160,31,'X',208,15,',','8',255,'c','J',244,3,11,250,129,5,
253,192,130,'~','`','A','?',176,160,31,'X','p',254,199,148,232,7,22,244,3,
11,250,177,'Y',174,222,'w','O',239,250,238,'C',191,25,150,217,185,232,'W',
'w',159,239,'~',25,238,187,205,208,159,'i',134,27,149,148,182,183,190,'f',
167,183,'{',227,181,'w',165,184,16,'B','J',227,253,'>',133,152,'g',139,167,
'3',205,'?',234,'q','x',232,'6',227,'K',177,'>',207,225,173,'|',185,189,16,
193,'-',186,135,155,219,'~',237,'}','S',']',137,174,186,249,'x',223,245,235,
251,166,'~',157,248,'1',206,190,216,191,225,228,250,'w',178,254,'c',25,215,
127,200,193,207,22,'o',178,136,158,215,255,24,252,209,159,';',245,248,133,
174,127,0,0,0,0,0,240,243,251,7,233,'Q','N','O',0,240,0,0};
#endif
#if ARCHIVE_VERSION_STAMP >= 1009000
/* libarchive < 1.9 does not support this. */
/* GNU tar "posix" sparse format 1.0, as created by gtar 1.17 */
static unsigned char archive_1_0_gtar_1_17[] = {
31,139,8,0,' ','%',193,'F',0,3,237,215,205,'n',26,'I',20,134,'a',214,'\\',
5,'7',16,168,255,234,'^','x',155,'d',21,'E',138,230,2,'Z','I','/',24,197,
'N',4,142,'d',205,213,'O',1,182,245,217,178,'A',163,'C',220,131,242,'>',155,
'n',183,'m',14,'?','o',161,174,229,234,243,'p',247,'q',28,190,141,155,237,
'2',';',23,211,'j',251,'s',216,'l',199,217,249,184,166,164,180,';',250,154,
157,30,247,130,207,'3',239,'J','q','!',132,148,218,'u',31,'S',142,179,197,
221,25,159,195,171,'~','m','o',135,'M','{','*',214,199,185,127,'-',143,199,
11,17,194,226,195,167,191,150,135,207,'|','y','=',252,253,'c','s',229,231,
207,174,174,'o',218,'U','7',15,'E',175,222,12,215,227,213,225,'|',30,189,
254,'f','3',14,223,183,235,127,198,171,232,'S',174,161,155,7,183,24,'n',215,
237,207,189,239,170,'+',209,'U',191,187,246,245,233,'5','7',159,250,205,248,
3,'-','W',237,131,251,178,255,220,222,175,191,143,191,229,'+',224,196,250,
143,187,229,242,184,254,'c','i',235,'?',251,28,'f',139,'7','Y','D',15,235,
191,181,'x',244,239,'N',253,254,'B',215,127,156,247,'M',',',243,236,195,220,
183,211,174,134,253,249,195,218,'e','U',226,136,'a',234,'\'',128,139,'F',
'?',211,'Z',190,'v',255,31,206,'7',227,244,253,127,'}','~',255,159,'c',229,
254,255,'-',252,167,251,255,250,202,253,127,187,'[',8,'/','n',0,250,'~',255,
'f',248,23,'v',0,129,29,192,255,193,177,251,255,'s','}',5,28,']',255,237,
'6','3',':',255,252,254,'?',164,202,253,255,'[',232,251,215,'6',0,'a','w',
238,186,195,'f',160,157,215,148,246,231,169,157,151,206,237,207,243,238,220,
31,254,183,180,243,156,15,255,219,29,222,132,195,185,'<','~','/',143,239,
157,12,240,'^','&',248,' ','#','|',148,25,'>',201,16,'_','d',138,'/',250,
'2',170,206,233,'t','N','/','s',130,147,'9',193,203,156,16,'d','N','H','2',
'\'','$',153,19,178,190,'_','E',230,132,170,'s',':',157,211,203,156,232,'d',
'N',12,'2','\'',6,153,19,163,'n',204,146,'~','0','Y',230,196,'"','s','b',
213,'9',157,204,185,127,'9',238,254,7,153,147,244,243,'O',26,'@','z','R',
128,'&',144,180,129,164,17,'$',173,' ','i',6,'I',';',200,218,'A',214,14,178,
'v',144,181,131,172,29,'d',237,' ','k',7,'Y',';',200,218,'A',214,14,138,'v',
'P',180,131,162,29,20,237,160,'h',7,'E',';','(',218,'A',209,14,138,'v','P',
180,131,170,29,'T',237,160,'j',7,'U',';',168,218,'A',213,14,170,'v','P',181,
131,170,29,'t',218,'A',167,29,'t',218,'A',167,29,'t',218,'A',167,29,'t',218,
'A',247,228,203,224,201,183,129,'v',208,'i',7,189,'v',208,'k',7,189,'v',208,
'k',7,189,'v',208,'k',7,189,'v',208,'k',7,253,'C',7,190,143,220,'o','X',177,
127,131,5,253,192,130,'~','`','A','?',176,160,31,'X',208,15,',',172,253,208,
31,',',232,7,22,244,3,11,250,129,5,253,192,130,'~','`','A','?',176,'`',255,
143,')',209,15,',',232,7,22,244,3,11,250,129,5,253,192,130,'~','`',193,254,
31,'S',162,31,'X',208,15,',',232,7,22,244,3,11,250,129,5,253,192,130,253,
'?',166,'D','?',176,160,31,'X',208,15,',',232,7,22,244,3,11,250,129,5,251,
127,'L',137,'~','`','A','?',176,160,31,'X',208,15,',',232,7,22,244,3,11,246,
255,152,18,253,192,130,'~','`','A','?',176,160,31,'X',208,15,',',232,7,22,
236,255,'1','%',250,129,5,253,192,130,'~','`','A','?',176,160,31,'X',208,
15,',',216,255,'c','J',244,3,11,250,129,5,253,192,130,'~','`','A','?',176,
160,31,'X',176,255,199,148,232,7,22,244,3,11,250,129,5,253,192,130,'~','`',
'A','?',176,'`',255,143,')',209,15,',',232,7,22,244,3,11,250,129,5,253,192,
130,'~','`',193,254,31,'S',162,31,'X',208,15,',',232,7,22,244,3,11,250,129,
5,253,192,130,253,'?',166,'D','?',176,160,31,'X',208,143,205,'r',245,'y',
184,251,'8',14,223,198,205,'v',153,157,139,'i','u',243,227,230,221,246,231,
176,217,142,'g',154,225,154,146,210,238,232,'k','v','z','<','h',231,222,149,
226,'B',8,')',181,235,'>',133,'v','X',220,157,'i',254,'Q',191,182,183,195,
166,'=',21,235,227,220,191,148,199,227,133,8,'n','1',220,174,175,199,'+',
239,187,234,'J','t',213,205,219,181,175,207,175,'M',253,'<',241,'{',156,'}',
177,191,224,228,250,'w',178,254,'c','i',235,'?',228,224,'g',139,'7','Y','D',
15,235,191,5,127,244,239,'N',253,254,'B',215,'?',0,0,0,128,'?',199,191,200,
'e','(',171,0,240,0,0};
#endif
/*
* The following test archive is a little odd. First, it's uncompressed,
* because that exercises some of the block reassembly code a little harder.
* Second, it includes some leading comments prior to the sparse block
* description. GNU tar doesn't do this, but I think it should, so I
* want to ensure that libarchive correctly ignores such comments.
*/
#if ARCHIVE_VERSION_STAMP >= 1009000
/* Because it's uncompressed, I've made this archive a bit simpler. */
struct archive_contents files_1_0b[] = {
{ "sparse", archive_contents_sparse },
{ "non-sparse", archive_contents_nonsparse },
{ NULL, NULL }
};
static unsigned char archive_1_0b[] = {
'.','/','P','a','x','H','e','a','d','e','r','s','.','7','5','4','7','/','s',
'p','a','r','s','e',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0','0','6','4','4',0,'0','0','0','1','7',
'5','0',0,'0','0','0','1','7','5','0',0,'0','0','0','0','0','0','0','0','2',
'1','5',0,'1','0','6','5','7','4','5','4','6','1','3',0,'0','1','3','4','2',
'5',0,' ','x',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s',
't','a','r',0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,'0','0','0','0','0','0','0',0,'0','0','0','0','0','0','0',0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,'2','2',' ','G','N','U','.','s','p','a','r','s',
'e','.','m','a','j','o','r','=','1',10,'2','2',' ','G','N','U','.','s','p',
'a','r','s','e','.','m','i','n','o','r','=','0',10,'2','6',' ','G','N','U',
'.','s','p','a','r','s','e','.','n','a','m','e','=','s','p','a','r','s','e',
10,'3','1',' ','G','N','U','.','s','p','a','r','s','e','.','r','e','a','l',
's','i','z','e','=','3','1','4','5','7','2','8',10,'2','0',' ','a','t','i',
'm','e','=','1','1','8','6','8','7','9','7','9','9',10,'2','0',' ','c','t',
'i','m','e','=','1','1','8','6','8','7','9','5','2','8',10,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'.','/','G',
'N','U','S','p','a','r','s','e','F','i','l','e','.','7','5','4','7','/','s',
'p','a','r','s','e',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,'0','0','0','0','6','4','4',0,'0','0','0','1','7','5','0',
0,'0','0','0','1','7','5','0',0,'0','0','0','0','0','0','0','3','0','0','0',
0,'1','0','6','5','7','4','5','4','0','5','0',0,'0','1','5','1','1','2',0,
' ','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a',
'r',0,'0','0','t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,'t','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,'0','0','0','0','0','0','0',0,'0','0','0','0','0','0','0',0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
/* 32 added bytes containing extra comments at beginning of sparse block */
'#','!','g','n','u','-','s','p','a','r','s','e','-','f','o','r','m','a',
't',10,'#','f','o','r','m','a','t',':','1','.','0',10,
'3',10,'9','9','9','9','3','6',10,'5','1','2',
10,'1','9','9','9','8','7','2',10,'5','1','2',10,'3','1','4','5','7','2',
'8',10,'0',10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,'0','0','0','0','6','4','4',0,'0','0','0','1','7','5','0',
0,'0','0','0','1','7','5','0',0,'0','0','0','0','0','0','0','0','0','5','0',
0,'1','0','6','5','7','4','5','4','6','1','3',0,'0','1','4','2','1','2',0,
' ','x',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a',
'r',0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0',
'0','0','0','0','0',0,'0','0','0','0','0','0','0',0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,'2','0',' ','a','t','i','m','e','=','1','1','8','6','8','7',
'9','7','9','9',10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,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,'0','0','0','0','6','4','4',0,'0','0','0','1','7','5','0',0,'0','0','0',
'1','7','5','0',0,'0','0','0','0','0','0','0','0','0','0','1',0,'1','0','6',
'5','7','4','5','4','0','7','0',0,'0','1','2','5','3','1',0,' ','0',0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r',0,'0','0',
't','i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'t',
'i','m',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0',
'0','0','0','0','0',0,'0','0','0','0','0','0','0',0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
#endif
/*
* A tricky piece of code that verifies the contents of a sparse
* archive entry against a description as defined at the top of this
@ -795,29 +178,25 @@ static unsigned char archive_1_0b[] = {
*/
#define min(a,b) ((a) < (b) ? (a) : (b))
/*
* A convenience wrapper that adds the size of the buffer and the
* name of the buffer to any call.
*/
#define verify_archive(buffer, contents) \
_verify_archive(buffer, sizeof(buffer), #buffer, contents)
static void
_verify_archive(void *buffer, size_t length, const char *name,
struct archive_contents *ac)
verify_archive_file(const char *name, struct archive_contents *ac)
{
char path[512];
struct archive_entry *ae;
struct archive *a;
int err;
/* data, size, offset of next expected block. */
struct contents expect;
/* data, size, offset of block read from archive. */
struct contents actual;
struct archive *a;
sprintf(path, "%s/%s", refdir, name);
assert((a = archive_read_new()) != NULL);
assert(0 == archive_read_support_compression_all(a));
assert(0 == archive_read_support_format_tar(a));
assert(0 == read_open_memory(a, buffer, length, 3));
failure("Can't open %s", path);
assert(0 == archive_read_open_filename(a, path, 3));
while (ac->filename != NULL) {
struct contents *cts = ac->contents;
@ -831,7 +210,7 @@ _verify_archive(void *buffer, size_t length, const char *name,
(const void **)&actual.d,
&actual.s, &actual.o))) {
while (actual.s > 0) {
char c = *(char *)actual.d;
char c = *(const char *)actual.d;
if(actual.o < expect.o) {
/*
* Any byte before the expected
@ -892,35 +271,51 @@ _verify_archive(void *buffer, size_t length, const char *name,
#endif
}
DEFINE_TEST(test_read_format_gtar_sparse)
{
/*
FILE *t = fopen("archive_1_0.tgz", "w");
fwrite(archive_1_0, sizeof(archive_1_0), 1, t);
fclose(t);
*/
verify_archive(archive_old_gtar_1_13, files);
/* Two archives that use the "GNU tar sparse format". */
verify_archive_file("test_read_format_gtar_sparse_1_13.tgz", files);
verify_archive_file("test_read_format_gtar_sparse_1_17.tgz", files);
/*
* libarchive < 1.9 doesn't support the newer sparse formats
* from GNU tar 1.15 and 1.16.
* libarchive < 1.9 doesn't support the newer --posix sparse formats
* from GNU tar 1.15 and later.
*/
#if ARCHIVE_VERSION_STAMP < 1009000
skipping("read support for GNUtar sparse format 0.0");
skipping("read support for GNUtar --posix sparse formats");
#else
verify_archive(archive_0_0_gtar_1_17, files);
#endif
#if ARCHIVE_VERSION_STAMP < 1009000
skipping("read support for GNUtar sparse format 0.1");
#else
verify_archive(archive_0_1_gtar_1_17, files);
#endif
#if ARCHIVE_VERSION_STAMP < 1009000
skipping("read support for GNUtar sparse format 1.0");
#else
verify_archive(archive_1_0_gtar_1_17, files);
verify_archive(archive_1_0b, files_1_0b);
/*
* An archive created by GNU tar 1.17 using --posix --sparse-format=0.1
*/
verify_archive_file(
"test_read_format_gtar_sparse_1_17_posix00.tgz",
files);
/*
* An archive created by GNU tar 1.17 using --posix --sparse-format=0.1
*/
verify_archive_file(
"test_read_format_gtar_sparse_1_17_posix01.tgz",
files);
/*
* An archive created by GNU tar 1.17 using --posix --sparse-format=1.0
*/
verify_archive_file(
"test_read_format_gtar_sparse_1_17_posix10.tgz",
files);
/*
* The last test archive here is a little odd. First, it's
* uncompressed, because that exercises some of the block
* reassembly code a little harder. Second, it includes some
* leading comments prior to the sparse block description.
* GNU tar doesn't do this, but I think it should, so I want
* to ensure that libarchive correctly ignores such comments.
* Dump the file, looking for "#!gnu-sparse-format" starting
* at byte 0x600.
*/
verify_archive_file(
"test_read_format_gtar_sparse_1_17_posix10_modified.tar",
files);
#endif
}

View File

@ -0,0 +1,26 @@
begin 644 test_read_format_gtar_sparse_1_13.tgz
M'XL(`&&";$<``^W72VX;1Q2%X<Y.N($`=>NYD*Q``P\\L&.(\OYSNP/)LGE`
M!SDF.D#^SP,G94&\7?VS']<O3\_7#]M#E2AE]KZ54F*-\O[O7<W_W:*LUJ)$
M]%R/M>;:+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
MCP?3N7<U1N^\3W'A?`HY+E9W)YI_U+?M[;"97HKU>>[?RL_CF0AN-=Q>78^7
MWO<6>BS.+Z=K'Y]>F_MUXM<X^6)_QJOKW^GZ]]/Z#]G5Q>I-%M'#^I^"/_IW
5KSU^INL?````P._C!\JB`&$`\```
`
end

File diff suppressed because it is too large Load Diff

View File

@ -110,6 +110,9 @@ DEFINE_TEST(test_read_format_isorr_bz2)
assertEqualInt(1, archive_entry_ctime(ae));
assertEqualInt(0, archive_entry_stat(ae)->st_nlink);
assertEqualInt(0, archive_entry_uid(ae));
assertEqualIntA(a, ARCHIVE_EOF,
archive_read_data_block(a, &p, &size, &offset));
assertEqualInt(size, 0);
/* A directory. */
assert(0 == archive_read_next_header(a, &ae));

View File

@ -0,0 +1,113 @@
/*-
* Copyright (c) 2003-2007 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"
__FBSDID("$FreeBSD$");
/* Single entry with a hardlink. */
static unsigned char archive[] = {
"#mtree\n"
"file type=file uid=18 mode=0123\n"
"dir type=dir\n"
" file\\040with\\040space type=file uid=18\n"
" ..\n"
"file\\04with\\040space\n"
"dir2 type=dir\n"
" dir3a type=dir\n"
" indir3a\n"
"dir2/fullindir2 type=file mode=0777\n"
" ..\n"
" indir2\n"
" dir3b type=dir\n"
" indir3b\n"
" ..\n"
" ..\n"
"notindir\n"
"dir2/fullindir2 mode=0644\n"
};
DEFINE_TEST(test_read_format_mtree)
{
struct archive_entry *ae;
struct archive *a;
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK,
archive_read_support_compression_all(a));
assertEqualIntA(a, ARCHIVE_OK,
archive_read_support_format_all(a));
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, archive, sizeof(archive)));
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualInt(archive_format(a), ARCHIVE_FORMAT_MTREE_V1);
assertEqualString(archive_entry_pathname(ae), "file");
assertEqualInt(archive_entry_uid(ae), 18);
assert(S_ISREG(archive_entry_mode(ae)));
assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0123);
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString(archive_entry_pathname(ae), "dir");
assert(S_ISDIR(archive_entry_mode(ae)));
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString(archive_entry_pathname(ae), "dir/file with space");
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString(archive_entry_pathname(ae), "file\\04with space");
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString(archive_entry_pathname(ae), "dir2");
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString(archive_entry_pathname(ae), "dir2/dir3a");
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString(archive_entry_pathname(ae), "dir2/dir3a/indir3a");
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString(archive_entry_pathname(ae), "dir2/fullindir2");
assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644);
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString(archive_entry_pathname(ae), "dir2/indir2");
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString(archive_entry_pathname(ae), "dir2/dir3b");
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString(archive_entry_pathname(ae), "dir2/dir3b/indir3b");
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString(archive_entry_pathname(ae), "notindir");
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
assertEqualInt(ARCHIVE_OK, archive_read_close(a));
#if ARCHIVE_API_VERSION > 1
assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
#else
archive_read_finish(a);
#endif
}

View File

@ -48,6 +48,9 @@ DEFINE_TEST(test_read_format_zip)
struct archive_entry *ae;
struct archive *a;
char *buff[128];
const void *pv;
size_t s;
off_t o;
assert((a = archive_read_new()) != NULL);
assertA(0 == archive_read_support_compression_all(a));
@ -57,6 +60,9 @@ DEFINE_TEST(test_read_format_zip)
assertEqualString("dir/", archive_entry_pathname(ae));
assertEqualInt(1179604249, archive_entry_mtime(ae));
assertEqualInt(0, archive_entry_size(ae));
assertEqualIntA(a, ARCHIVE_EOF,
archive_read_data_block(a, &pv, &s, &o));
assertEqualInt(s, 0);
assertA(0 == archive_read_next_header(a, &ae));
assertEqualString("file1", archive_entry_pathname(ae));
assertEqualInt(1179604289, archive_entry_mtime(ae));

View File

@ -29,9 +29,9 @@ DEFINE_TEST(test_read_pax_truncated)
{
struct archive_entry *ae;
struct archive *a;
size_t used, i;
ssize_t used, i;
size_t buff_size = 1000000;
size_t filedata_size = 100000;
ssize_t filedata_size = 100000;
char *buff = malloc(buff_size);
char *buff2 = malloc(buff_size);
char *filedata = malloc(filedata_size);

View File

@ -41,7 +41,7 @@ test_filename(const char *prefix, int dlen, int flen)
struct archive *a;
size_t used;
size_t prefix_length = 0;
int i = 0;
unsigned i = 0;
if (prefix) {
strcpy(filename, prefix);

View File

@ -0,0 +1,309 @@
/*-
* Copyright (c) 2003-2007 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"
__FBSDID("$FreeBSD$");
#include <errno.h>
#include <stdlib.h>
#include <string.h>
/*
* This is a somewhat tricky test that verifies the ability to
* write and read very large entries to tar archives. It
* writes entries from 2GB up to 1TB to an archive in memory.
* The memory storage here carefully avoids actually storing
* any part of the file bodies, so it runs very quickly and requires
* very little memory. If you're willing to wait a few minutes,
* you should be able to exercise petabyte entries with this code.
*/
/*
* Each file is built up by duplicating the following block.
*/
static size_t filedatasize;
static void *filedata;
/*
* We store the archive as blocks of data generated by libarchive,
* each possibly followed by bytes of file data.
*/
struct memblock {
struct memblock *next;
size_t size;
void *buff;
off_t filebytes;
};
/*
* The total memory store is just a list of memblocks plus
* some accounting overhead.
*/
struct memdata {
off_t filebytes;
void *buff;
struct memblock *first;
struct memblock *last;
};
/* The following size definitions simplify things below. */
#define KB ((off_t)1024)
#define MB ((off_t)1024 * KB)
#define GB ((off_t)1024 * MB)
#define TB ((off_t)1024 * GB)
#if ARCHIVE_API_VERSION < 2
static ssize_t memory_read_skip(struct archive *, void *, size_t request);
#else
static off_t memory_read_skip(struct archive *, void *, off_t request);
#endif
static ssize_t memory_read(struct archive *, void *, const void **buff);
static ssize_t memory_write(struct archive *, void *, const void *, size_t);
static ssize_t
memory_write(struct archive *a, void *_private, const void *buff, size_t size)
{
struct memdata *private = _private;
struct memblock *block;
(void)a;
/*
* Since libarchive tries to behave in a zero-copy manner, if
* you give a pointer to filedata to the library, a pointer
* into that data will (usually) pop out here. This way, we
* can tell the difference between filedata and library header
* and metadata.
*/
if ((const char *)filedata <= (const char *)buff
&& (const char *)buff < (const char *)filedata + filedatasize) {
/* We don't need to store a block of file data. */
private->last->filebytes += size;
} else {
/* Yes, we're assuming the very first write is metadata. */
/* It's header or metadata, copy and save it. */
block = (struct memblock *)malloc(sizeof(*block));
memset(block, 0, sizeof(*block));
block->size = size;
block->buff = malloc(size);
memcpy(block->buff, buff, size);
if (private->last == NULL) {
private->first = private->last = block;
} else {
private->last->next = block;
private->last = block;
}
block->next = NULL;
}
return (size);
}
static ssize_t
memory_read(struct archive *a, void *_private, const void **buff)
{
struct memdata *private = _private;
struct memblock *block;
ssize_t size;
(void)a;
free(private->buff);
private->buff = NULL;
if (private->first == NULL) {
private->last = NULL;
return (ARCHIVE_EOF);
}
if (private->filebytes > 0) {
/*
* We're returning file bytes, simulate it by
* passing blocks from the template data.
*/
if (private->filebytes > (off_t)filedatasize)
size = filedatasize;
else
size = (ssize_t)private->filebytes;
private->filebytes -= size;
*buff = filedata;
} else {
/*
* We need to get some real data to return.
*/
block = private->first;
private->first = block->next;
size = block->size;
if (block->buff != NULL) {
private->buff = block->buff;
*buff = block->buff;
} else {
private->buff = NULL;
*buff = filedata;
}
private->filebytes = block->filebytes;
free(block);
}
return (size);
}
#if ARCHIVE_API_VERSION < 2
static ssize_t
memory_read_skip(struct archive *a, void *private, size_t skip)
{
(void)a; /* UNUSED */
(void)private; /* UNUSED */
(void)skip; /* UNUSED */
return (0);
}
#else
static off_t
memory_read_skip(struct archive *a, void *_private, off_t skip)
#endif
{
struct memdata *private = _private;
(void)a;
if (private->first == NULL) {
private->last = NULL;
return (0);
}
if (private->filebytes > 0) {
if (private->filebytes < skip)
skip = private->filebytes;
private->filebytes -= skip;
} else {
skip = 0;
}
return (skip);
}
DEFINE_TEST(test_tar_large)
{
/* The sizes of the entries we're going to generate. */
static off_t tests[] = {
/* Test for 32-bit signed overflow. */
2 * GB - 1, 2 * GB, 2 * GB + 1,
/* Test for 32-bit unsigned overflow. */
4 * GB - 1, 4 * GB, 4 * GB + 1,
/* 8GB is the "official" max for ustar. */
8 * GB - 1, 8 * GB, 8 * GB + 1,
/* Bend ustar a tad and you can get 64GB (12 octal digits). */
64 * GB - 1, 64 * GB,
/* And larger entries that require non-ustar extensions. */
256 * GB, 1 * TB, 0 };
int i;
char namebuff[64];
struct memdata memdata;
struct archive_entry *ae;
struct archive *a;
off_t filesize, writesize;
filedatasize = 1 * MB;
filedata = malloc(filedatasize);
memset(filedata, 0xAA, filedatasize);
memset(&memdata, 0, sizeof(memdata));
/*
* Open an archive for writing.
*/
a = archive_write_new();
archive_write_set_format_pax_restricted(a);
archive_write_set_bytes_per_block(a, 0); /* No buffering. */
archive_write_open(a, &memdata, NULL, memory_write, NULL);
/*
* Write a series of large files to it.
*/
for (i = 0; tests[i] > 0; i++) {
assert((ae = archive_entry_new()) != NULL);
sprintf(namebuff, "file_%d", i);
archive_entry_copy_pathname(ae, namebuff);
archive_entry_set_mode(ae, S_IFREG | 0755);
filesize = tests[i];
archive_entry_set_size(ae, filesize);
assertA(0 == archive_write_header(a, ae));
archive_entry_free(ae);
/*
* Write the actual data to the archive.
*/
while (filesize > 0) {
writesize = filedatasize;
if (writesize > filesize)
writesize = filesize;
assertA(writesize == archive_write_data(a, filedata, writesize));
filesize -= writesize;
}
}
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, "lastfile");
archive_entry_set_mode(ae, S_IFREG | 0755);
assertA(0 == archive_write_header(a, ae));
archive_entry_free(ae);
/* Close out the archive. */
assertA(0 == archive_write_close(a));
#if ARCHIVE_API_VERSION > 1
assertA(0 == archive_write_finish(a));
#else
archive_write_finish(a);
#endif
/*
* Open the same archive for reading.
*/
a = archive_read_new();
archive_read_support_format_tar(a);
archive_read_open2(a, &memdata, NULL,
memory_read, memory_read_skip, NULL);
/*
* Read entries back.
*/
for (i = 0; tests[i] > 0; i++) {
assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
sprintf(namebuff, "file_%d", i);
assertEqualString(namebuff, archive_entry_pathname(ae));
assert(tests[i] == archive_entry_size(ae));
}
assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
assertEqualString("lastfile", archive_entry_pathname(ae));
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
/* Close out the archive. */
assertA(0 == archive_read_close(a));
#if ARCHIVE_API_VERSION > 1
assertA(0 == archive_read_finish(a));
#else
archive_read_finish(a);
#endif
free(memdata.buff);
free(filedata);
}

View File

@ -244,16 +244,18 @@ DEFINE_TEST(test_write_disk_perms)
failure("Opportunistic SUID failure shouldn't return error.");
assertEqualInt(0, archive_write_finish_entry(a));
assert(archive_entry_clear(ae) != NULL);
archive_entry_copy_pathname(ae, "file_bad_suid2");
archive_entry_set_mode(ae, S_IFREG | S_ISUID | 0742);
archive_entry_set_uid(ae, getuid() + 1);
archive_write_disk_set_options(a,
ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_OWNER);
assertA(0 == archive_write_header(a, ae));
/* Owner change should fail here. */
failure("Non-opportunistic SUID failure should return error.");
assertEqualInt(ARCHIVE_WARN, archive_write_finish_entry(a));
if (getuid() != 0) {
assert(archive_entry_clear(ae) != NULL);
archive_entry_copy_pathname(ae, "file_bad_suid2");
archive_entry_set_mode(ae, S_IFREG | S_ISUID | 0742);
archive_entry_set_uid(ae, getuid() + 1);
archive_write_disk_set_options(a,
ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_OWNER);
assertA(0 == archive_write_header(a, ae));
/* Owner change should fail here. */
failure("Non-opportunistic SUID failure should return error.");
assertEqualInt(ARCHIVE_WARN, archive_write_finish_entry(a));
}
/* Write a regular file with ARCHIVE_EXTRACT_PERM & SGID bit */
assert(archive_entry_clear(ae) != NULL);
@ -403,10 +405,13 @@ DEFINE_TEST(test_write_disk_perms)
failure("file_bad_suid: st.st_mode=%o", st.st_mode);
assert((st.st_mode & 07777) == (0742));
/* SUID bit should NOT have been set here. */
assert(0 == stat("file_bad_suid2", &st));
failure("file_bad_suid2: st.st_mode=%o", st.st_mode);
assert((st.st_mode & 07777) == (0742));
/* Some things don't fail if you're root, so suppress this. */
if (getuid() != 0) {
/* SUID bit should NOT have been set here. */
assert(0 == stat("file_bad_suid2", &st));
failure("file_bad_suid2: st.st_mode=%o", st.st_mode);
assert((st.st_mode & 07777) == (0742));
}
/* SGID should be set here. */
assert(0 == stat("file_perm_sgid", &st));

View File

@ -37,6 +37,7 @@ test_format(int (*set_format)(struct archive *))
size_t used;
size_t buffsize = 1000000;
char *buff;
int damaged = 0;
buff = malloc(buffsize);
@ -66,6 +67,26 @@ test_format(int (*set_format)(struct archive *))
archive_entry_free(ae);
assertA(8 == archive_write_data(a, "12345678", 9));
/*
* Write another file to it.
*/
assert((ae = archive_entry_new()) != NULL);
archive_entry_set_mtime(ae, 1, 10);
assert(1 == archive_entry_mtime(ae));
assert(10 == archive_entry_mtime_nsec(ae));
p = strdup("file2");
archive_entry_copy_pathname(ae, p);
strcpy(p, "XXXX");
free(p);
assertEqualString("file2", archive_entry_pathname(ae));
archive_entry_set_mode(ae, S_IFREG | 0755);
assert((S_IFREG | 0755) == archive_entry_mode(ae));
archive_entry_set_size(ae, 4);
assertA(0 == archive_write_header(a, ae));
archive_entry_free(ae);
assertA(4 == archive_write_data(a, "1234", 5));
/*
* Write a directory to it.
*/
@ -89,6 +110,22 @@ test_format(int (*set_format)(struct archive *))
archive_write_finish(a);
#endif
/*
* Damage the second entry to test the search-ahead recovery.
*/
{
int i;
for (i = 80; i < 150; i++) {
if (memcmp(buff + i, "07070", 5) == 0) {
damaged = 1;
buff[i] = 'X';
break;
}
}
}
failure("Unable to locate the second header for damage-recovery test.");
assert(damaged = 1);
/*
* Now, read the data back.
*/
@ -97,29 +134,48 @@ test_format(int (*set_format)(struct archive *))
assertA(0 == archive_read_support_compression_all(a));
assertA(0 == archive_read_open_memory(a, buff, used));
assertA(0 == archive_read_next_header(a, &ae));
assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
assert(1 == archive_entry_mtime(ae));
assertEqualInt(1, archive_entry_mtime(ae));
/* Not the same as above: cpio doesn't store hi-res times. */
assert(0 == archive_entry_mtime_nsec(ae));
assert(0 == archive_entry_atime(ae));
assert(0 == archive_entry_ctime(ae));
assertEqualString("file", archive_entry_pathname(ae));
assert((S_IFREG | 0755) == archive_entry_mode(ae));
assert(8 == archive_entry_size(ae));
assertEqualInt((S_IFREG | 0755), archive_entry_mode(ae));
assertEqualInt(8, archive_entry_size(ae));
assertA(8 == archive_read_data(a, filedata, 10));
assert(0 == memcmp(filedata, "12345678", 8));
/*
* Read the second file back.
*/
if (!damaged) {
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualInt(1, archive_entry_mtime(ae));
/* Not the same as above: cpio doesn't store hi-res times. */
assert(0 == archive_entry_mtime_nsec(ae));
assert(0 == archive_entry_atime(ae));
assert(0 == archive_entry_ctime(ae));
assertEqualString("file2", archive_entry_pathname(ae));
assert((S_IFREG | 0755) == archive_entry_mode(ae));
assertEqualInt(4, archive_entry_size(ae));
assertEqualIntA(a, 4, archive_read_data(a, filedata, 10));
assert(0 == memcmp(filedata, "1234", 4));
}
/*
* Read the dir entry back.
*/
assertA(0 == archive_read_next_header(a, &ae));
assert(11 == archive_entry_mtime(ae));
assertEqualIntA(a,
damaged ? ARCHIVE_WARN : ARCHIVE_OK,
archive_read_next_header(a, &ae));
assertEqualInt(11, archive_entry_mtime(ae));
assert(0 == archive_entry_mtime_nsec(ae));
assert(0 == archive_entry_atime(ae));
assert(0 == archive_entry_ctime(ae));
assertEqualString("dir", archive_entry_pathname(ae));
assert((S_IFDIR | 0755) == archive_entry_mode(ae));
assertEqualInt((S_IFDIR | 0755), archive_entry_mode(ae));
assertEqualInt(0, archive_entry_size(ae));
assertEqualIntA(a, 0, archive_read_data(a, filedata, 10));

View File

@ -0,0 +1,172 @@
/*-
* Copyright (c) 2003-2007 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"
__FBSDID("$FreeBSD$");
static int
is_hex(const char *p, size_t l)
{
while (l > 0) {
if (*p >= 0 && *p <= '9') {
/* Ascii digit */
} else if (*p >= 'a' && *p <= 'f') {
/* lowercase letter a-f */
} else {
/* Not hex. */
return (0);
}
--l;
++p;
}
return (1);
}
/*
* Detailed verification that cpio 'newc' archives are written with
* the correct format.
*/
DEFINE_TEST(test_write_format_cpio_newc)
{
struct archive *a;
struct archive_entry *entry;
char *buff, *e;
size_t buffsize = 100000;
size_t used;
buff = malloc(buffsize);
/* Create a new archive in memory. */
assert((a = archive_write_new()) != NULL);
assertEqualIntA(a, 0, archive_write_set_format_cpio_newc(a));
assertEqualIntA(a, 0, archive_write_set_compression_none(a));
assertEqualIntA(a, 0, archive_write_open_memory(a, buff, buffsize, &used));
/*
* Add various files to it.
* TODO: Extend this to cover more filetypes.
*/
assert((entry = archive_entry_new()) != NULL);
archive_entry_set_mtime(entry, 1, 10);
archive_entry_set_pathname(entry, "file");
archive_entry_set_mode(entry, S_IFREG | 0664);
archive_entry_set_size(entry, 10);
archive_entry_set_uid(entry, 80);
archive_entry_set_gid(entry, 90);
archive_entry_set_dev(entry, 12);
archive_entry_set_ino(entry, 89);
archive_entry_set_nlink(entry, 1);
assertEqualIntA(a, 0, archive_write_header(a, entry));
archive_entry_free(entry);
assertEqualIntA(a, 10, archive_write_data(a, "1234567890", 10));
assert((entry = archive_entry_new()) != NULL);
archive_entry_set_mtime(entry, 2, 20);
archive_entry_set_pathname(entry, "dir");
archive_entry_set_mode(entry, S_IFDIR | 0775);
archive_entry_set_size(entry, 10);
archive_entry_set_nlink(entry, 2);
assertEqualIntA(a, 0, archive_write_header(a, entry));
archive_entry_free(entry);
assertEqualIntA(a, 0, archive_write_data(a, "1234567890", 10));
#if ARCHIVE_API_VERSION > 1
assert(0 == archive_write_finish(a));
#else
archive_write_finish(a);
#endif
/*
* Verify the archive format.
*/
e = buff;
/* First entry is "file" */
assert(is_hex(e, 110)); /* Entire header is hex digits. */
assertEqualMem(e + 0, "070701", 6); /* Magic */
assertEqualMem(e + 6, "00000059", 8); /* ino */
assertEqualMem(e + 14, "000081b4", 8); /* Mode */
assertEqualMem(e + 22, "00000050", 8); /* uid */
assertEqualMem(e + 30, "0000005a", 8); /* gid */
assertEqualMem(e + 38, "00000001", 8); /* nlink */
assertEqualMem(e + 46, "00000001", 8); /* mtime */
assertEqualMem(e + 54, "0000000a", 8); /* File size */
assertEqualMem(e + 62, "00000000", 8); /* devmajor */
assertEqualMem(e + 70, "0000000c", 8); /* devminor */
assertEqualMem(e + 78, "00000000", 8); /* rdevmajor */
assertEqualMem(e + 86, "00000000", 8); /* rdevminor */
assertEqualMem(e + 94, "00000005", 8); /* Name size */
assertEqualMem(e + 102, "00000000", 8); /* CRC */
assertEqualMem(e + 110, "file\0\0", 6); /* Name contents */
assertEqualMem(e + 116, "1234567890", 10); /* File body */
assertEqualMem(e + 126, "\0\0", 2); /* Pad to multiple of 4 */
e += 128;
/* Second entry is "dir" */
assert(is_hex(e, 110));
assertEqualMem(e + 0, "070701", 6); /* Magic */
assertEqualMem(e + 6, "00000000", 8); /* ino */
assertEqualMem(e + 14, "000041fd", 8); /* Mode */
assertEqualMem(e + 22, "00000000", 8); /* uid */
assertEqualMem(e + 30, "00000000", 8); /* gid */
assertEqualMem(e + 38, "00000002", 8); /* nlink */
assertEqualMem(e + 46, "00000002", 8); /* mtime */
assertEqualMem(e + 54, "00000000", 8); /* File size */
assertEqualMem(e + 62, "00000000", 8); /* devmajor */
assertEqualMem(e + 70, "00000000", 8); /* devminor */
assertEqualMem(e + 78, "00000000", 8); /* rdevmajor */
assertEqualMem(e + 86, "00000000", 8); /* rdevminor */
assertEqualMem(e + 94, "00000004", 8); /* Name size */
assertEqualMem(e + 102, "00000000", 8); /* CRC */
assertEqualMem(e + 110, "dir\0", 4); /* name */
assertEqualMem(e + 114, "\0\0", 2); /* Pad to multiple of 4 */
e += 116;
/* TODO: Verify other types of entries. */
/* Last entry is end-of-archive marker. */
assert(is_hex(e, 76));
assertEqualMem(e + 0, "070701", 6); /* Magic */
assertEqualMem(e + 6, "00000000", 8); /* ino */
assertEqualMem(e + 14, "00000000", 8); /* Mode */
assertEqualMem(e + 22, "00000000", 8); /* uid */
assertEqualMem(e + 30, "00000000", 8); /* gid */
assertEqualMem(e + 38, "00000001", 8); /* nlink */
assertEqualMem(e + 46, "00000000", 8); /* mtime */
assertEqualMem(e + 54, "00000000", 8); /* File size */
assertEqualMem(e + 62, "00000000", 8); /* devmajor */
assertEqualMem(e + 70, "00000000", 8); /* devminor */
assertEqualMem(e + 78, "00000000", 8); /* rdevmajor */
assertEqualMem(e + 86, "00000000", 8); /* rdevminor */
assertEqualMem(e + 94, "0000000b", 8); /* Name size */
assertEqualMem(e + 102, "00000000", 8); /* CRC */
assertEqualMem(e + 110, "TRAILER!!!\0", 11); /* Name */
assertEqualMem(e + 121, "\0\0\0", 3); /* Pad to multiple of 4 bytes */
e += 124;
assertEqualInt(used, e - buff);
free(buff);
}

View File

@ -0,0 +1,224 @@
/*-
* Copyright (c) 2003-2007 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"
__FBSDID("$FreeBSD$");
static int
is_octal(const char *p, size_t l)
{
while (l > 0) {
if (*p < '0' || *p > '7')
return (0);
--l;
++p;
}
return (1);
}
/*
* Detailed verification that cpio 'odc' archives are written with
* the correct format.
*/
DEFINE_TEST(test_write_format_cpio_odc)
{
struct archive *a;
struct archive_entry *entry;
char *buff, *e;
size_t buffsize = 100000;
size_t used;
buff = malloc(buffsize);
/* Create a new archive in memory. */
assert((a = archive_write_new()) != NULL);
assertEqualIntA(a, 0, archive_write_set_format_cpio(a));
assertEqualIntA(a, 0, archive_write_set_compression_none(a));
assertEqualIntA(a, 0, archive_write_open_memory(a, buff, buffsize, &used));
/*
* Add various files to it.
* TODO: Extend this to cover more filetypes.
*/
/* "file" with 10 bytes of content */
assert((entry = archive_entry_new()) != NULL);
archive_entry_set_mtime(entry, 1, 10);
archive_entry_set_pathname(entry, "file");
archive_entry_set_mode(entry, S_IFREG | 0664);
archive_entry_set_size(entry, 10);
archive_entry_set_uid(entry, 80);
archive_entry_set_gid(entry, 90);
archive_entry_set_dev(entry, 12);
archive_entry_set_ino(entry, 89);
archive_entry_set_nlink(entry, 2);
assertEqualIntA(a, 0, archive_write_header(a, entry));
archive_entry_free(entry);
assertEqualIntA(a, 10, archive_write_data(a, "1234567890", 10));
/* Hardlink to "file" with 10 bytes of content */
assert((entry = archive_entry_new()) != NULL);
archive_entry_set_mtime(entry, 1, 10);
archive_entry_set_pathname(entry, "linkfile");
archive_entry_set_mode(entry, S_IFREG | 0664);
archive_entry_set_size(entry, 10);
archive_entry_set_uid(entry, 80);
archive_entry_set_gid(entry, 90);
archive_entry_set_dev(entry, 12);
archive_entry_set_ino(entry, 89);
archive_entry_set_nlink(entry, 2);
assertEqualIntA(a, 0, archive_write_header(a, entry));
archive_entry_free(entry);
assertEqualIntA(a, 10, archive_write_data(a, "1234567890", 10));
/* "dir" */
assert((entry = archive_entry_new()) != NULL);
archive_entry_set_mtime(entry, 2, 20);
archive_entry_set_pathname(entry, "dir");
archive_entry_set_mode(entry, S_IFDIR | 0775);
archive_entry_set_size(entry, 10);
archive_entry_set_nlink(entry, 2);
assertEqualIntA(a, 0, archive_write_header(a, entry));
archive_entry_free(entry);
/* Write of data to dir should fail == zero bytes get written. */
assertEqualIntA(a, 0, archive_write_data(a, "1234567890", 10));
/* "symlink" pointing to "file" */
assert((entry = archive_entry_new()) != NULL);
archive_entry_set_mtime(entry, 3, 30);
archive_entry_set_pathname(entry, "symlink");
archive_entry_set_mode(entry, S_IFLNK | 0664);
archive_entry_set_symlink(entry,"file");
archive_entry_set_size(entry, 0);
archive_entry_set_uid(entry, 88);
archive_entry_set_gid(entry, 98);
archive_entry_set_dev(entry, 12);
archive_entry_set_ino(entry, 90);
archive_entry_set_nlink(entry, 1);
assertEqualIntA(a, 0, archive_write_header(a, entry));
archive_entry_free(entry);
/* Write of data to symlink should fail == zero bytes get written. */
assertEqualIntA(a, 0, archive_write_data(a, "1234567890", 10));
#if ARCHIVE_API_VERSION > 1
assert(0 == archive_write_finish(a));
#else
archive_write_finish(a);
#endif
/*
* Verify the archive format.
*/
e = buff;
/* "file" */
assert(is_octal(e, 76)); /* Entire header is octal digits. */
assertEqualMem(e + 0, "070707", 6); /* Magic */
assertEqualMem(e + 6, "000014", 6); /* dev */
assertEqualMem(e + 12, "000131", 6); /* ino */
assertEqualMem(e + 18, "100664", 6); /* Mode */
assertEqualMem(e + 24, "000120", 6); /* uid */
assertEqualMem(e + 30, "000132", 6); /* gid */
assertEqualMem(e + 36, "000002", 6); /* nlink */
assertEqualMem(e + 42, "000000", 6); /* rdev */
assertEqualMem(e + 48, "00000000001", 11); /* mtime */
assertEqualMem(e + 59, "000005", 6); /* Name size */
assertEqualMem(e + 65, "00000000012", 11); /* File size */
assertEqualMem(e + 76, "file\0", 5); /* Name contents */
assertEqualMem(e + 81, "1234567890", 10); /* File contents */
e += 91;
/* hardlink to "file" */
assert(is_octal(e, 76)); /* Entire header is octal digits. */
assertEqualMem(e + 0, "070707", 6); /* Magic */
assertEqualMem(e + 6, "000014", 6); /* dev */
assertEqualMem(e + 12, "000131", 6); /* ino */
assertEqualMem(e + 18, "100664", 6); /* Mode */
assertEqualMem(e + 24, "000120", 6); /* uid */
assertEqualMem(e + 30, "000132", 6); /* gid */
assertEqualMem(e + 36, "000002", 6); /* nlink */
assertEqualMem(e + 42, "000000", 6); /* rdev */
assertEqualMem(e + 48, "00000000001", 11); /* mtime */
assertEqualMem(e + 59, "000011", 6); /* Name size */
assertEqualMem(e + 65, "00000000012", 11); /* File size */
assertEqualMem(e + 76, "linkfile\0", 9); /* Name contents */
assertEqualMem(e + 85, "1234567890", 10); /* File contents */
e += 95;
/* "dir" */
assert(is_octal(e, 76));
assertEqualMem(e + 0, "070707", 6); /* Magic */
assertEqualMem(e + 6, "000000", 6); /* dev */
assertEqualMem(e + 12, "000000", 6); /* ino */
assertEqualMem(e + 18, "040775", 6); /* Mode */
assertEqualMem(e + 24, "000000", 6); /* uid */
assertEqualMem(e + 30, "000000", 6); /* gid */
assertEqualMem(e + 36, "000002", 6); /* Nlink */
assertEqualMem(e + 42, "000000", 6); /* rdev */
assertEqualMem(e + 48, "00000000002", 11); /* mtime */
assertEqualMem(e + 59, "000004", 6); /* Name size */
assertEqualMem(e + 65, "00000000000", 11); /* File size */
assertEqualMem(e + 76, "dir\0", 4); /* name */
e += 80;
/* "symlink" pointing to "file" */
assert(is_octal(e, 76)); /* Entire header is octal digits. */
assertEqualMem(e + 0, "070707", 6); /* Magic */
assertEqualMem(e + 6, "000014", 6); /* dev */
assertEqualMem(e + 12, "000132", 6); /* ino */
assertEqualMem(e + 18, "120664", 6); /* Mode */
assertEqualMem(e + 24, "000130", 6); /* uid */
assertEqualMem(e + 30, "000142", 6); /* gid */
assertEqualMem(e + 36, "000001", 6); /* nlink */
assertEqualMem(e + 42, "000000", 6); /* rdev */
assertEqualMem(e + 48, "00000000003", 11); /* mtime */
assertEqualMem(e + 59, "000010", 6); /* Name size */
assertEqualMem(e + 65, "00000000004", 11); /* File size */
assertEqualMem(e + 76, "symlink\0", 8); /* Name contents */
assertEqualMem(e + 84, "file", 4); /* File contents == link target */
e += 88;
/* TODO: Verify other types of entries. */
/* Last entry is end-of-archive marker. */
assert(is_octal(e, 76));
assertEqualMem(e + 0, "070707", 6); /* Magic */
assertEqualMem(e + 6, "000000", 6); /* dev */
assertEqualMem(e + 12, "000000", 6); /* ino */
assertEqualMem(e + 18, "000000", 6); /* Mode */
assertEqualMem(e + 24, "000000", 6); /* uid */
assertEqualMem(e + 30, "000000", 6); /* gid */
assertEqualMem(e + 36, "000001", 6); /* Nlink */
assertEqualMem(e + 42, "000000", 6); /* rdev */
assertEqualMem(e + 48, "00000000000", 11); /* mtime */
assertEqualMem(e + 59, "000013", 6); /* Name size */
assertEqualMem(e + 65, "00000000000", 11); /* File size */
assertEqualMem(e + 76, "TRAILER!!!\0", 11); /* Name */
e += 87;
assertEqualInt(used, e - buff);
free(buff);
}