Merge r294:337,r348:350 from libarchive.googlecode.com: A lot

of work to make libarchive work on Windows.
This commit is contained in:
Tim Kientzle 2009-03-03 17:02:51 +00:00
parent 6b0ff427a5
commit 690f818afd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=189308
61 changed files with 7871 additions and 321 deletions

View file

@ -47,7 +47,11 @@
/* These should match the types used in 'struct stat' */
#ifdef _WIN32
#define __LA_INT64_T __int64
#define __LA_SSIZE_T long
# if defined(_WIN64)
# define __LA_SSIZE_T __int64
# else
# define __LA_SSIZE_T long
# endif
#define __LA_UID_T unsigned int
#define __LA_GID_T unsigned int
#else

View file

@ -62,6 +62,9 @@ __FBSDID("$FreeBSD$");
#ifdef HAVE_WCHAR_H
#include <wchar.h>
#endif
#ifdef _WIN32
#include <windows.h>
#endif
#include "archive.h"
#include "archive_entry.h"
@ -227,9 +230,15 @@ aes_get_wcs(struct aes *aes)
w = (wchar_t *)malloc((wcs_length + 1) * sizeof(wchar_t));
if (w == NULL)
__archive_errx(1, "No memory for aes_get_wcs()");
#ifndef _WIN32
r = mbstowcs(w, aes->aes_mbs.s, wcs_length);
w[wcs_length] = 0;
#else
r = MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS,
aes->aes_mbs.s, (int)aes->aes_mbs.length, w,
(int)wcs_length);
#endif
if (r > 0) {
w[r] = 0;
aes->aes_set |= AES_SET_WCS;
return (aes->aes_wcs = w);
}

View file

@ -40,6 +40,9 @@ __FBSDID("$FreeBSD$");
#ifdef HAVE_WCHAR_H
#include <wchar.h>
#endif
#ifdef _WIN32
#include <windows.h>
#endif
#include "archive_private.h"
#include "archive_string.h"
@ -175,6 +178,7 @@ __archive_strappend_int(struct archive_string *as, int d, int base)
return (as);
}
#ifndef _WIN32
/*
* Home-grown wctomb for UTF-8.
*/
@ -375,3 +379,83 @@ __archive_string_utf8_w(struct archive_string *as)
*dest++ = L'\0';
return (ws);
}
#else
static struct archive_string *
my_archive_strappend_w(struct archive_string *as,
unsigned int codepage, const wchar_t *w)
{
char *p;
int l, wl;
BOOL useDefaultChar = FALSE;
wl = (int)wcslen(w);
l = wl * 4 + 4;
p = malloc(l);
if (p == NULL)
__archive_errx(1, "Out of memory");
/* To check a useDefaultChar is to simulate error handling of
* the my_wcstombs() which is running on non Windows system with
* wctomb().
* And to set NULL for last argument is necessary when a codepage
* is not CP_ACP(current locale).
*/
l = WideCharToMultiByte(codepage, 0, w, wl, p, l, NULL,
(codepage == CP_ACP) ? &useDefaultChar : NULL);
if (l == 0 || useDefaultChar) {
free(p);
return (NULL);
}
__archive_string_append(as, p, l);
free(p);
return (as);
}
/*
* Translates a wide character string into UTF-8 and appends
* to the archive_string. Note: returns NULL if conversion fails.
*/
struct archive_string *
__archive_strappend_w_utf8(struct archive_string *as, const wchar_t *w)
{
return (my_archive_strappend_w(as, CP_UTF8, w));
}
/*
* Translates a wide character string into current locale character set
* and appends to the archive_string. Note: returns NULL if conversion
* fails.
*/
struct archive_string *
__archive_strappend_w_mbs(struct archive_string *as, const wchar_t *w)
{
return (my_archive_strappend_w(as, CP_ACP, w));
}
/*
* Return a wide-character string by converting this archive_string
* from UTF-8.
*/
wchar_t *
__archive_string_utf8_w(struct archive_string *as)
{
wchar_t *ws;
int n;
ws = (wchar_t *)malloc((as->length + 1) * sizeof(wchar_t));
if (ws == NULL)
__archive_errx(1, "Out of memory");
n = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS,
as->s, (int)as->length, ws, (int)as->length);
if (n == 0) {
free(ws);
return (NULL);
}
ws[n] = L'\0';
return (ws);
}
#endif /* !_WIN32 */

View file

@ -83,6 +83,9 @@ __FBSDID("$FreeBSD$");
#ifdef HAVE_UTIME_H
#include <utime.h>
#endif
#ifdef _WIN32
#include <windows.h>
#endif
#include "archive.h"
#include "archive_string.h"
@ -516,6 +519,9 @@ static ssize_t
write_data_block(struct archive_write_disk *a, const char *buff, size_t size)
{
uint64_t start_size = size;
#if _WIN32
HANDLE handle;
#endif
ssize_t bytes_written = 0;
ssize_t block_size = 0, bytes_to_write;
@ -524,6 +530,9 @@ write_data_block(struct archive_write_disk *a, const char *buff, size_t size)
"Attempt to write to an empty file");
return (ARCHIVE_WARN);
}
#if _WIN32
handle = (HANDLE)_get_osfhandle(a->fd);
#endif
if (a->flags & ARCHIVE_EXTRACT_SPARSE) {
#if HAVE_STRUCT_STAT_ST_BLKSIZE
@ -572,7 +581,23 @@ write_data_block(struct archive_write_disk *a, const char *buff, size_t size)
if (a->offset + bytes_to_write > block_end)
bytes_to_write = block_end - a->offset;
}
#ifdef _WIN32
/* Seek if necessary to the specified offset. */
if (offset != a->fd_offset) {
LARGE_INTEGER distance;
distance.QuadPart = offset;
if (!SetFilePointerEx(handle, distance, NULL, FILE_BEGIN)) {
archive_set_error(&a->archive, _dosmaperr(GetLastError()),
"Seek failed");
return (ARCHIVE_FATAL);
}
}
if (!WriteFile(handle, buff, bytes_to_write, &bytes_written, NULL)) {
archive_set_error(&a->archive, _dosmaperr(GetLastError()),
"Write failed");
return (ARCHIVE_WARN);
}
#else
/* Seek if necessary to the specified offset. */
if (a->offset != a->fd_offset) {
if (lseek(a->fd, a->offset, SEEK_SET) < 0) {
@ -589,6 +614,7 @@ write_data_block(struct archive_write_disk *a, const char *buff, size_t size)
archive_set_error(&a->archive, errno, "Write failed");
return (ARCHIVE_WARN);
}
#endif
buff += bytes_written;
size -= bytes_written;
a->offset += bytes_written;
@ -1186,7 +1212,11 @@ _archive_write_close(struct archive *_a)
if (p->fixup & TODO_TIMES) {
#ifdef HAVE_UTIMES
/* {f,l,}utimes() are preferred, when available. */
#ifdef __timeval
struct __timeval times[2];
#else
struct timeval times[2];
#endif
times[0].tv_sec = p->atime;
times[0].tv_usec = p->atime_nanos / 1000;
#ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME
@ -1717,7 +1747,11 @@ set_time(int fd, int mode, const char *name,
time_t atime, long atime_nsec,
time_t mtime, long mtime_nsec)
{
#ifdef __timeval
struct __timeval times[2];
#else
struct timeval times[2];
#endif
times[0].tv_sec = atime;
times[0].tv_usec = atime_nsec / 1000;

View file

@ -203,6 +203,16 @@ utf8_encode(const wchar_t *wval)
utf8len = 0;
for (wp = wval; *wp != L'\0'; ) {
wc = *wp++;
if (wc >= 0xd800 && wc <= 0xdbff
&& *wp >= 0xdc00 && *wp <= 0xdfff) {
/* This is a surrogate pair. Combine into a
* full Unicode value before encoding into
* UTF-8. */
wc = (wc - 0xd800) << 10; /* High 10 bits */
wc += (*wp++ - 0xdc00); /* Low 10 bits */
wc += 0x10000; /* Skip BMP */
}
if (wc <= 0x7f)
utf8len++;
else if (wc <= 0x7ff)
@ -226,6 +236,12 @@ utf8_encode(const wchar_t *wval)
for (wp = wval, p = utf8_value; *wp != L'\0'; ) {
wc = *wp++;
if (wc >= 0xd800 && wc <= 0xdbff
&& *wp >= 0xdc00 && *wp <= 0xdfff) {
/* Combine surrogate pair. */
wc = (wc - 0xd800) << 10;
wc += *wp++ - 0xdc00 + 0x10000;
}
if (wc <= 0x7f) {
*p++ = (char)wc;
} else if (wc <= 0x7ff) {

View file

@ -44,7 +44,7 @@
#define ENVBASE "LIBARCHIVE" /* Prefix for environment variables. */
#define EXTRA_DUMP(x) archive_error_string((struct archive *)(x))
#define EXTRA_VERSION archive_version()
#define KNOWNREF "test_compat_gtar_1.tgz.uu"
#define KNOWNREF "test_compat_gtar_1.tar.uu"
__FBSDID("$FreeBSD$");
/*
@ -81,7 +81,20 @@ static int skips = 0;
static int assertions = 0;
/* Directory where uuencoded reference files can be found. */
static char *refdir;
static const char *refdir;
#ifdef _WIN32
static void
invalid_paramter_handler(const wchar_t * expression,
const wchar_t * function, const wchar_t * file,
unsigned int line, uintptr_t pReserved)
{
/* nop */
}
#endif
/*
* My own implementation of the standard assert() macro emits the
@ -751,7 +764,11 @@ static int test_run(int i, const char *tmpdir)
/* If there were no failures, we can remove the work dir. */
if (failures == failures_before) {
if (!keep_temp_files && chdir(tmpdir) == 0) {
#ifndef _WIN32
systemf("rm -rf %s", tests[i].name);
#else
systemf("rmdir /S /Q %s", tests[i].name);
#endif
}
}
/* Return appropriate status. */
@ -844,19 +861,18 @@ extract_reference_file(const char *name)
}
static char *
get_refdir(const char *tmpdir)
get_refdir(void)
{
char tried[512] = { '\0' };
char buff[128];
char *pwd, *p;
/* Get the current dir. */
systemf("/bin/pwd > %s/refdir", tmpdir);
pwd = slurpfile(NULL, "%s/refdir", tmpdir);
/* XXX Visual C++ uses _getcwd() XXX */
pwd = getcwd(NULL, 0);
while (pwd[strlen(pwd) - 1] == '\n')
pwd[strlen(pwd) - 1] = '\0';
printf("PWD: %s\n", pwd);
systemf("rm %s/refdir", tmpdir);
/* Look for a known file. */
snprintf(buff, sizeof(buff), "%s", pwd);
@ -904,24 +920,24 @@ get_refdir(const char *tmpdir)
int main(int argc, char **argv)
{
static const int limit = sizeof(tests) / sizeof(tests[0]);
int i, tests_run = 0, tests_failed = 0, opt;
int i, tests_run = 0, tests_failed = 0, option;
time_t now;
char *refdir_alloc = NULL;
char *progname, *p;
const char *tmp;
const char *progname = LIBRARY "_test";
const char *tmp, *option_arg, *p;
char tmpdir[256];
char tmpdir_timestamp[256];
/*
* 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;
}
(void)argc; /* UNUSED */
#ifdef _WIN32
/* To stop to run the default invalid parameter handler. */
_set_invalid_parameter_handler(invalid_paramter_handler);
/* for open() to a binary mode. */
_set_fmode(_O_BINARY);
/* Disable annoying assertion message box. */
_CrtSetReportMode(_CRT_ASSERT, 0);
#endif
#ifdef PROGRAM
/* Get the target program from environment, if available. */
@ -947,39 +963,60 @@ int main(int argc, char **argv)
refdir = getenv(ENVBASE "_TEST_FILES");
/*
* Parse options.
* Parse options, without using getopt(), which isn't available
* on all platforms.
*/
while ((opt = getopt(argc, argv, "dkp:qr:v")) != -1) {
switch (opt) {
case 'd':
dump_on_failure = 1;
break;
case 'k':
keep_temp_files = 1;
break;
case 'p':
++argv; /* Skip program name */
while (*argv != NULL) {
p = *argv++;
if (*p++ != '-')
usage(progname);
while (*p != '\0') {
option = *p++;
option_arg = NULL;
/* If 'opt' takes an argument, parse that. */
if (option == 'p' || option == 'r') {
if (*p != '\0')
option_arg = p;
else if (*argv == NULL) {
fprintf(stderr,
"Option -%c requires argument.\n",
option);
usage(progname);
} else
option_arg = *argv++;
p = ""; /* End of this option word. */
}
/* Now, handle the option. */
switch (option) {
case 'd':
dump_on_failure = 1;
break;
case 'k':
keep_temp_files = 1;
break;
case 'p':
#ifdef PROGRAM
testprog = optarg;
testprog = option_arg;
#else
usage(progname);
usage(progname);
#endif
break;
case 'q':
quiet_flag++;
break;
case 'r':
refdir = optarg;
break;
case 'v':
verbose = 1;
break;
case '?':
default:
usage(progname);
break;
case 'q':
quiet_flag++;
break;
case 'r':
refdir = option_arg;
break;
case 'v':
verbose = 1;
break;
default:
usage(progname);
}
}
}
argc -= optind;
argv += optind;
/*
* Sanity-check that our options make sense.
@ -1016,7 +1053,7 @@ int main(int argc, char **argv)
* the "usual places."
*/
if (refdir == NULL)
refdir = refdir_alloc = get_refdir(tmpdir);
refdir = refdir_alloc = get_refdir();
/*
* Banner with basic information.
@ -1035,7 +1072,7 @@ int main(int argc, char **argv)
/*
* Run some or all of the individual tests.
*/
if (argc == 0) {
if (*argv == NULL) {
/* Default: Run all tests. */
for (i = 0; i < limit; i++) {
if (test_run(i, tmpdir))

View file

@ -107,7 +107,7 @@ memory_read(struct archive *a, void *client_data, const void **buff)
*buff = mine->copy_buff;
mine->buffer += size;
return (size);
return ((ssize_t)size);
}
/*

View file

@ -45,7 +45,11 @@
#error Oops: No config.h and no pre-built configuration in test.h.
#endif
#ifndef _WIN32
#include <dirent.h>
#else
#include <direct.h>
#endif
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
@ -68,6 +72,16 @@
#define __FBSDID(a) /* null */
#endif
#ifdef _WIN32
#define LOCALE_DE "deu"
#else
#define LOCALE_DE "de_DE.UTF-8"
#endif
#ifndef O_BINARY
#define O_BINARY 0
#endif
/*
* Redefine DEFINE_TEST for use in defining the test functions.
*/

View file

@ -454,7 +454,7 @@ DEFINE_TEST(test_acl_pax)
/* Write out the data we generated to a file for manual inspection. */
assert(-1 < (fd = open("testout", O_WRONLY | O_CREAT | O_TRUNC, 0775)));
assert(used == (size_t)write(fd, buff, used));
assert(used == (size_t)write(fd, buff, (unsigned int)used));
close(fd);
/* Write out the reference data to a file for manual inspection. */
@ -466,7 +466,7 @@ DEFINE_TEST(test_acl_pax)
failure("Generated pax archive does not match reference; check 'testout' and 'reference' files.");
assert(0 == memcmp(buff, reference, sizeof(reference)));
failure("Generated pax archive does not match reference; check 'testout' and 'reference' files.");
assertEqualInt(used, sizeof(reference));
assertEqualInt((int)used, sizeof(reference));
/* Read back each entry and check that the ACL data is right. */
assert(NULL != (a = archive_read_new()));

View file

@ -82,8 +82,12 @@ compat_bzip2(const char *name)
DEFINE_TEST(test_compat_bzip2)
{
#if HAVE_BZLIB_H
compat_bzip2("test_compat_bzip2_1.tbz");
compat_bzip2("test_compat_bzip2_2.tbz");
#else
skipping("Need bzlib");
#endif
}

View file

@ -40,7 +40,7 @@ __FBSDID("$FreeBSD$");
static void
test_compat_gtar_1(void)
{
char name[] = "test_compat_gtar_1.tgz";
char name[] = "test_compat_gtar_1.tar";
struct archive_entry *ae;
struct archive *a;
int r;
@ -99,7 +99,7 @@ test_compat_gtar_1(void)
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_compression(a), ARCHIVE_COMPRESSION_NONE);
assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_GNUTAR);
assertEqualInt(ARCHIVE_OK, archive_read_close(a));

View file

@ -0,0 +1,232 @@
$FreeBSD$
begin 644 test_compat_gtar_1.tar
M+B\N+T!,;VYG3&EN:P``````````````````````````````````````````
M````````````````````````````````````````````````````````````
M`````````````"`@("`@,"``("`@("`P(``@("`@(#`@`"`@("`@("`@,S$Q
M("`@("`@("`@("`P("`Q,#<P,0`@3```````````````````````````````
M````````````````````````````````````````````````````````````
M``````````````````````````````````````````!U<W1A<B`@`')O;W0`
M````````````````````````````````````=VAE96P`````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M```````````````````````Q,C,T-38W.#DP,3(S-#4V-S@Y,#$R,S0U-C<X
M.3`Q,C,T-38W.#DP,3(S-#4V-S@Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S
M-#4V-S@Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S@Y,#$R,S0U-C<X
M.3`Q,C,T-38W.#DP,3(S-#4V-S@Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S
M-#4V-S@Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S@Y,```````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M`````````````````````````````````````````````#$R,S0U-C<X.3`Q
M,C,T-38W.#DP,3(S-#4V-S@Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V
M-S@Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S@Y,#$R,S0U-C<X.0`Q
M,#`V-#0@`"`@,3<U,"``("`Q-S4P(``@("`@("`@("`@,"`Q,#<R-C<P,#$W
M,R`@,C$P,C``(#``````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````=7-T87(@(`!T:6T`````````````````
M`````````````````````'1I;0``````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````+B\N+T!,;VYG3&EN:P``````````````````````````````````
M````````````````````````````````````````````````````````````
M`````````````````````"`@("`@,"``("`@("`P(``@("`@(#`@`"`@("`@
M("`@,S$Q("`@("`@("`@("`P("`Q,#<P,``@2P``````````````````````
M````````````````````````````````````````````````````````````
M``````````````````````````````````````````````````!U<W1A<B`@
M`')O;W0`````````````````````````````````````=VAE96P`````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M```````````````````````````````Q,C,T-38W.#DP,3(S-#4V-S@Y,#$R
M,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S@Y,#$R,S0U-C<X.3`Q,C,T-38W
M.#DP,3(S-#4V-S@Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S@Y,#$R
M,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S@Y,#$R,S0U-C<X.3`Q,C,T-38W
M.#DP,3(S-#4V-S@Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S@Y,```
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M`````````````````````````````````````````````````````"XO+B]`
M3&]N9TQI;FL`````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M```````@("`@(#`@`"`@("`@,"``("`@("`P(``@("`@("`@(#,Q,2`@("`@
M("`@("`@,"`@,3`W,#$`($P`````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````=7-T87(@(`!R;V]T````````
M`````````````````````````````'=H965L````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````86)C9&5F9VAI:F%B8V1E9F=H:6IA8F-D969G:&EJ86)C
M9&5F9VAI:F%B8V1E9F=H:6IA8F-D969G:&EJ86)C9&5F9VAI:F%B8V1E9F=H
M:6IA8F-D969G:&EJ86)C9&5F9VAI:F%B8V1E9F=H:6IA8F-D969G:&EJ86)C
M9&5F9VAI:F%B8V1E9F=H:6IA8F-D969G:&EJ86)C9&5F9VAI:F%B8V1E9F=H
M:6IA8F-D969G:&EJ86)C9&5F9VAI:F%B8V1E9F=H:6H`````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M``````````````````````````````````````!A8F-D969G:&EJ86)C9&5F
M9VAI:F%B8V1E9F=H:6IA8F-D969G:&EJ86)C9&5F9VAI:F%B8V1E9F=H:6IA
M8F-D969G:&EJ86)C9&5F9VAI:F%B8V1E9F=H:6IA8F-D969G:&D`,3(P-S4U
M(``@(#$W-3`@`"`@,3<U,"``("`@("`@("`@(#`@,3`W,C8W,#`R-#,@(#0T
M-3(Q`"`R,3(S-#4V-S@Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S@Y
M,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S@Y,#$R,S0U-C<X.3`Q,C,T
M-38W.#DP,3(S-#4V-S@Y`'5S=&%R("``=&EM````````````````````````
M``````````````!T:6T`````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
9````````````````````````````````````
`
end

View file

@ -1,10 +0,0 @@
$FreeBSD$
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

@ -82,6 +82,7 @@ verify(const char *name)
DEFINE_TEST(test_compat_gzip)
{
#if HAVE_ZLIB_H
/* This sample has been 'split', each piece compressed separately,
* then concatenated. Gunzip will emit the concatenated result. */
/* Not supported in libarchive 2.6 and earlier */
@ -89,6 +90,9 @@ DEFINE_TEST(test_compat_gzip)
/* This sample has been compressed as a single stream, but then
* some unrelated garbage text has been appended to the end. */
verify("test_compat_gzip_2.tgz");
#else
skipping("Need zlib");
#endif
}

View file

@ -63,7 +63,11 @@ test_compat_zip_1(void)
DEFINE_TEST(test_compat_zip)
{
#if HAVE_ZLIB_H
test_compat_zip_1();
#else
skipping("Need zlib");
#endif
}

View file

@ -31,6 +31,7 @@ DEFINE_TEST(test_empty_write)
struct archive_entry *ae;
struct archive *a;
size_t used;
int r;
/*
* Exercise a zero-byte write to a gzip-compressed archive.
@ -39,27 +40,29 @@ DEFINE_TEST(test_empty_write)
/* 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));
archive_entry_free(ae);
r = archive_write_set_compression_gzip(a);
if (r == ARCHIVE_FATAL) {
skipping("Empty write to gzip-compressed archive");
} else {
assertEqualIntA(a, ARCHIVE_OK, r);
assertEqualIntA(a, ARCHIVE_OK,
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));
archive_entry_free(ae);
/* THE TEST: write zero bytes to this entry. */
/* This used to crash. */
assertEqualIntA(a, 0, archive_write_data(a, "", 0));
/* 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_VERSION_NUMBER < 2000000
archive_write_finish(a);
#else
assertA(0 == archive_write_finish(a));
#endif
/* Close out the archive. */
assertA(0 == archive_write_close(a));
assertA(0 == archive_write_finish(a));
}
/*
* Again, with bzip2 compression.
@ -68,27 +71,28 @@ DEFINE_TEST(test_empty_write)
/* 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));
archive_entry_free(ae);
r = archive_write_set_compression_bzip2(a);
if (r == ARCHIVE_FATAL) {
skipping("Empty write to bzip2-compressed archive");
} else {
assertEqualIntA(a, ARCHIVE_OK, r);
assertEqualIntA(a, ARCHIVE_OK,
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));
archive_entry_free(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_VERSION_NUMBER < 2000000
archive_write_finish(a);
#else
assertA(0 == archive_write_finish(a));
#endif
/* 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));
assertA(0 == archive_write_finish(a));
}
/*
* For good measure, one more time with no compression.
@ -112,9 +116,5 @@ DEFINE_TEST(test_empty_write)
/* Close out the archive. */
assertA(0 == archive_write_close(a));
#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(a);
#else
assertA(0 == archive_write_finish(a));
#endif
}

View file

@ -287,20 +287,20 @@ DEFINE_TEST(test_entry)
assertEqualInt(0, archive_entry_xattr_next(e, &xname, &xval, &xsize));
assertEqualString(xname, "xattr1");
assertEqualString(xval, "xattrvalue1");
assertEqualInt(xsize, 12);
assertEqualInt((int)xsize, 12);
assertEqualInt(1, archive_entry_xattr_count(e));
assertEqualInt(ARCHIVE_WARN,
archive_entry_xattr_next(e, &xname, &xval, &xsize));
assertEqualString(xname, NULL);
assertEqualString(xval, NULL);
assertEqualInt(xsize, 0);
assertEqualInt((int)xsize, 0);
archive_entry_xattr_clear(e);
assertEqualInt(0, archive_entry_xattr_reset(e));
assertEqualInt(ARCHIVE_WARN,
archive_entry_xattr_next(e, &xname, &xval, &xsize));
assertEqualString(xname, NULL);
assertEqualString(xval, NULL);
assertEqualInt(xsize, 0);
assertEqualInt((int)xsize, 0);
archive_entry_xattr_add_entry(e, "xattr1", "xattrvalue1", 12);
assertEqualInt(1, archive_entry_xattr_reset(e));
archive_entry_xattr_add_entry(e, "xattr2", "xattrvalue2", 12);
@ -311,7 +311,7 @@ DEFINE_TEST(test_entry)
archive_entry_xattr_next(e, &xname, &xval, &xsize));
assertEqualString(xname, NULL);
assertEqualString(xval, NULL);
assertEqualInt(xsize, 0);
assertEqualInt((int)xsize, 0);
/*
@ -437,12 +437,12 @@ DEFINE_TEST(test_entry)
assertEqualInt(0, archive_entry_xattr_next(e2, &xname, &xval, &xsize));
assertEqualString(xname, "xattr1");
assertEqualString(xval, "xattrvalue");
assertEqualInt(xsize, 11);
assertEqualInt((int)xsize, 11);
assertEqualInt(ARCHIVE_WARN,
archive_entry_xattr_next(e2, &xname, &xval, &xsize));
assertEqualString(xname, NULL);
assertEqualString(xval, NULL);
assertEqualInt(xsize, 0);
assertEqualInt((int)xsize, 0);
#endif
/* Change the original */
@ -783,7 +783,7 @@ DEFINE_TEST(test_entry)
/*
* Exercise the character-conversion logic, if we can.
*/
if (NULL == setlocale(LC_ALL, "de_DE.UTF-8")) {
if (NULL == setlocale(LC_ALL, LOCALE_DE)) {
skipping("Can't exercise charset-conversion logic without"
" a suitable locale.");
} else {
@ -827,8 +827,8 @@ DEFINE_TEST(test_entry)
* "c89 plus GNU extensions.")
*/
wcscpy(wbuff, L"xxxAyyyBzzz");
wbuff[3] = 0x12345678;
wbuff[7] = 0x5678;
wbuff[3] = (wchar_t)0x12345678;
wbuff[7] = (wchar_t)0x5678;
/* A wide filename that cannot be converted to narrow. */
archive_entry_copy_pathname_w(e, wbuff);
failure("Converting wide characters from Unicode should fail.");

View file

@ -51,13 +51,19 @@ __FBSDID("$FreeBSD$");
static const char *
files[] = {
"test_fuzz_1.iso",
#if HAVE_BZLIB_H
"test_compat_bzip2_1.tbz",
"test_compat_gtar_1.tgz",
#endif
"test_compat_gtar_1.tar",
"test_compat_tar_hardlink_1.tar",
#if HAVE_ZLIB_H
"test_compat_zip_1.zip",
#endif
"test_read_format_gtar_sparse_1_17_posix10_modified.tar",
"test_read_format_tar_empty_filename.tar",
#if HAVE_ZLIB_H
"test_read_format_zip.zip",
#endif
NULL
};
@ -84,7 +90,7 @@ DEFINE_TEST(test_fuzz)
/* Fuzz < 1% of the bytes in the archive. */
memcpy(image, rawimage, size);
numbytes = rand() % (size / 100);
numbytes = (int)(rand() % (size / 100));
for (j = 0; j < numbytes; ++j)
image[rand() % size] = (char)rand();
@ -93,7 +99,7 @@ DEFINE_TEST(test_fuzz)
fd = open("after.test.failure.send.this.file."
"to.libarchive.maintainers.with.system.details",
O_WRONLY | O_CREAT | O_TRUNC, 0744);
write(fd, image, size);
write(fd, image, (off_t)size);
close(fd);
assert((a = archive_read_new()) != NULL);

View file

@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$");
*/
DEFINE_TEST(test_pax_filename_encoding_1)
{
static const char testname[] = "test_pax_filename_encoding.tar.gz";
static const char testname[] = "test_pax_filename_encoding.tar";
/*
* \314\214 is a valid 2-byte UTF-8 sequence.
* \374 is invalid in UTF-8.
@ -105,9 +105,9 @@ DEFINE_TEST(test_pax_filename_encoding_2)
* de_DE.UTF-8 seems to be commonly supported.
*/
/* If it doesn't exist, just warn and return. */
if (NULL == setlocale(LC_ALL, "de_DE.UTF-8")) {
if (NULL == setlocale(LC_ALL, LOCALE_DE)) {
skipping("invalid encoding tests require a suitable locale;"
" de_DE.UTF-8 not available on this system");
" %s not available on this system", LOCALE_DE);
return;
}

View file

@ -1,11 +0,0 @@
$FreeBSD$
begin 644 test_pax_filename_encoding.tar.gz
M'XL(`)4;VT<``^V6STK#0!#&<\Y3[!/HS/Z-ASVHEQ1$BE[L<4T6$DP32:-$
MG\%'\Y%Z,*7$UEJLE"91NK_+P.P>OF'X^&9LZM":V):GYCYZ?YOFQ5W]\NH=
M%`"0G).FHA*P7I>@E`1!22E!`9,$4#"0'JD/*V,[3[/*E(V4*IW^^&_7^W(4
M\EG_"13)HZD2W6Y_WFS?IT"B9EZKD8(0+)"!6/3,EQZ5/BIR>QF.KB8GL7W6
M0>!3VC;2O-"<H>#\S,>@[>99FC]H](>>VM'2G>M7[/(_@-CP/V-4>`2Z$K3.
MD?L_M%E6#"W",1CC;_D_[SW_*;+-_!><N?SO@R;_D[B,$E/.;*4O1M?G-Q/_
L%T<!1\7V/@IP\<T=!7^![ER_8H_\%PI=_O>!RW^'P^$X3CX`98.>C@`4````
`
end

View file

@ -0,0 +1,119 @@
$FreeBSD$
begin 644 test_pax_filename_encoding.tar
M4&%X2&5A9&5R+V%B8\R,;6YO6'AY>@``````````````````````````````
M````````````````````````````````````````````````````````````
M`````````````#`P,#8T-"``,#`Q-S4P(``P,#$W-3`@`#`P,#`P,#`P,38V
M(#$P-S8V-C`W,#,V(#`Q-3,P-@`@>```````````````````````````````
M````````````````````````````````````````````````````````````
M``````````````````````````````````````````!U<W1A<@`P,'1I;0``
M````````````````````````````````````=&EM````````````````````
M```````````````````P,#`P,#`@`#`P,#`P,"``````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M```````````````````````R,2!P871H/6%B8\R,;6YO_'AY>@HR,"!C=&EM
M93TQ,C`U-3,X-C@U"C(P(&%T:6UE/3$R,#4U,S@V,C8*,3<@4T-(24Q9+F1E
M=CTX.`HR,B!30TA)3%DN:6YO/30S,34T-#D*,3@@4T-(24Q9+FYL:6YK/3$*
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M`````````````````````````````````````````````&%B8\R,;6YO6'AY
M>@``````````````````````````````````````````````````````````
M```````````````````````````````````````````````````````````P
M,#`V-#0@`#`P,3<U,"``,#`Q-S4P(``P,#`P,#`P,#`P-2`Q,#<V-C8P-S`S
M-B`P,3,S,C4`(#``````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````=7-T87(`,#!T:6T`````````````````
M`````````````````````'1I;0``````````````````````````````````
M````,#`P,#`P(``P,#`P,#`@````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````2&5L;&\`````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M``````````````````````````````!087A(96%D97(O86)CS(QM;F_\>'EZ
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````,#`P-C0T(``P,#$W
M-3`@`#`P,3<U,"``,#`P,#`P,#`R,3,@,3`W-C8V,#<P,S8@,#$U-30S`"!X
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M`````````````'5S=&%R`#`P=&EM````````````````````````````````
M``````!T:6T``````````````````````````````````````#`P,#`P,"``
M,#`P,#`P(```````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M`````````````````````````````````````````````````````#(Q(&AD
M<F-H87)S970]0DE.05)9"C(Q('!A=&@]86)CS(QM;F_\>'EZ"C(P(&-T:6UE
M/3$R,#4U-#$W,S4*,C`@871I;64],3(P-34S.#8R-@HQ-R!30TA)3%DN9&5V
M/3@X"C(R(%-#2$E,62YI;F\]-#,Q-3$R-@HQ."!30TA)3%DN;FQI;FL],0H`
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````86)CS(QM;F_\>'EZ````````````````````````````
M````````````````````````````````````````````````````````````
M`````````````````````````````#`P,#8T-"``,#`Q-S4P(``P,#$W-3`@
M`#`P,#`P,#`P,#`U(#$P-S8V-C`W,#,V(#`Q,S4W,0`@,```````````````
M````````````````````````````````````````````````````````````
M``````````````````````````````````````````````````````````!U
M<W1A<@`P,'1I;0``````````````````````````````````````=&EM````
M```````````````````````````````````P,#`P,#`@`#`P,#`P,"``````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M``````````````````````````````````````!(96QL;P``````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
C````````````````````````````````````````````````
`
end

View file

@ -34,6 +34,8 @@ static unsigned char archive[] = {
DEFINE_TEST(test_read_compress_program)
{
int r;
#if ARCHIVE_VERSION_NUMBER < 1009000
skipping("archive_read_support_compression_program()");
#else
@ -41,7 +43,12 @@ DEFINE_TEST(test_read_compress_program)
struct archive *a;
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, 0, archive_read_support_compression_none(a));
assertEqualIntA(a, 0, archive_read_support_compression_program(a, "gunzip"));
r = archive_read_support_compression_program(a, "gunzip");
if (r == ARCHIVE_FATAL) {
skipping("archive_read_support_compression_program() unsupported on this platform");
return;
}
assertEqualIntA(a, ARCHIVE_OK, r);
assert(0 == archive_read_support_format_all(a));
assertEqualIntA(a, 0, archive_read_open_memory(a, archive, sizeof(archive)));
assertEqualIntA(a, 0, archive_read_next_header(a, &ae));

View file

@ -32,12 +32,16 @@ DEFINE_TEST(test_read_extract)
{
struct archive_entry *ae;
struct archive *a;
#ifndef _WIN32
struct stat st;
#endif
size_t used;
int i;
char *buff, *file_buff;
#ifndef _WIN32
int fd;
ssize_t bytes_read;
#endif
buff = malloc(BUFF_SIZE);
file_buff = malloc(FILE_BUFF_SIZE);
@ -134,6 +138,7 @@ DEFINE_TEST(test_read_extract)
assert(0 == archive_read_finish(a));
#endif
#ifndef _WIN32
/* Test the entries on disk. */
/* This first entry was extracted with ARCHIVE_EXTRACT_PERM,
* so the permissions should have been restored exactly,
@ -187,6 +192,7 @@ DEFINE_TEST(test_read_extract)
#endif
assert(0 == stat("symlink", &st));
assert(st.st_mode == (S_IFREG | 0755));
#endif
free(buff);
free(file_buff);

View file

@ -34,6 +34,7 @@ static unsigned char archive[] = {
DEFINE_TEST(test_read_format_cpio_bin_bz2)
{
#if HAVE_BZLIB_H
struct archive_entry *ae;
struct archive *a;
assert((a = archive_read_new()) != NULL);
@ -51,6 +52,9 @@ DEFINE_TEST(test_read_format_cpio_bin_bz2)
#else
assert(0 == archive_read_finish(a));
#endif
#else
skipping("Need bzlib");
#endif
}

View file

@ -33,6 +33,7 @@ static unsigned char archive[] = {
DEFINE_TEST(test_read_format_cpio_bin_gz)
{
#if HAVE_ZLIB_H
struct archive_entry *ae;
struct archive *a;
assert((a = archive_read_new()) != NULL);
@ -48,6 +49,9 @@ DEFINE_TEST(test_read_format_cpio_bin_gz)
#else
assert(0 == archive_read_finish(a));
#endif
#else
skipping("Need zlib");
#endif
}

View file

@ -34,6 +34,7 @@ static unsigned char archive[] = {
DEFINE_TEST(test_read_format_cpio_svr4_gzip)
{
#if HAVE_ZLIB_H
struct archive_entry *ae;
struct archive *a;
assert((a = archive_read_new()) != NULL);
@ -49,6 +50,9 @@ DEFINE_TEST(test_read_format_cpio_svr4_gzip)
#else
assert(0 == archive_read_finish(a));
#endif
#else
skipping("Need zlib");
#endif
}

View file

@ -25,7 +25,7 @@
#include "test.h"
__FBSDID("$FreeBSD$");
static unsigned char archive[] = { };
static unsigned char archive[] = { 0 };
DEFINE_TEST(test_read_format_empty)
{
@ -34,7 +34,7 @@ DEFINE_TEST(test_read_format_empty)
assert((a = archive_read_new()) != NULL);
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_open_memory(a, archive, 0));
assertA(ARCHIVE_EOF == archive_read_next_header(a, &ae));
assertA(archive_compression(a) == ARCHIVE_COMPRESSION_NONE);
assertA(archive_format(a) == ARCHIVE_FORMAT_EMPTY);
@ -45,5 +45,3 @@ DEFINE_TEST(test_read_format_empty)
assert(0 == archive_read_finish(a));
#endif
}

View file

@ -34,6 +34,7 @@ static unsigned char archive[] = {
DEFINE_TEST(test_read_format_gtar_gz)
{
#if HAVE_ZLIB_H
struct archive_entry *ae;
struct archive *a;
assert((a = archive_read_new()) != NULL);
@ -49,6 +50,9 @@ DEFINE_TEST(test_read_format_gtar_gz)
#else
assert(0 == archive_read_finish(a));
#endif
#else
skipping("Need zlib");
#endif
}

View file

@ -171,13 +171,6 @@ struct archive_contents {
{ NULL, NULL }
};
/*
* A tricky piece of code that verifies the contents of a sparse
* archive entry against a description as defined at the top of this
* source file.
*/
#define min(a,b) ((a) < (b) ? (a) : (b))
static void
verify_archive_file(const char *name, struct archive_contents *ac)
{
@ -251,7 +244,7 @@ verify_archive_file(const char *name, struct archive_contents *ac)
failure("%s: should be end of entry", name);
assertEqualIntA(a, err, ARCHIVE_EOF);
failure("%s: Size returned at EOF must be zero", name);
assertEqualInt(actual.s, 0);
assertEqualInt((int)actual.s, 0);
#if ARCHIVE_VERSION_NUMBER < 1009000
/* libarchive < 1.9 doesn't get this right */
skipping("offset of final sparse chunk");
@ -278,8 +271,8 @@ verify_archive_file(const char *name, struct archive_contents *ac)
DEFINE_TEST(test_read_format_gtar_sparse)
{
/* 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);
verify_archive_file("test_read_format_gtar_sparse_1_13.tar", files);
verify_archive_file("test_read_format_gtar_sparse_1_17.tar", files);
/*
* libarchive < 1.9 doesn't support the newer --posix sparse formats
@ -292,19 +285,19 @@ DEFINE_TEST(test_read_format_gtar_sparse)
* 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",
"test_read_format_gtar_sparse_1_17_posix00.tar",
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",
"test_read_format_gtar_sparse_1_17_posix01.tar",
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",
"test_read_format_gtar_sparse_1_17_posix10.tar",
files);
/*
* The last test archive here is a little odd. First, it's

File diff suppressed because it is too large Load diff

View file

@ -1,27 +0,0 @@
$FreeBSD$
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>;:+G\\=JR_?;V^/#U?+MO+QT]W?^YG__ZO[5O09L\]>MN1M__.7:IB
M/=HZO*[O2W<_('?U\.NG?_KUOQ+_(_0#G.=ZW/_K0S_C[OT_>FW?W?]C*[5&
M:]S_[]S_6V]J?=72?US_K92Q8L1JZB%A?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>>[?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

View file

@ -53,6 +53,7 @@ static unsigned char archive[] = {
DEFINE_TEST(test_read_format_iso_gz)
{
#if HAVE_ZLIB_H
struct archive_entry *ae;
struct archive *a;
assert((a = archive_read_new()) != NULL);
@ -68,6 +69,9 @@ DEFINE_TEST(test_read_format_iso_gz)
#else
assert(0 == archive_read_finish(a));
#endif
#else
skipping("Need zlib");
#endif
}

View file

@ -51,10 +51,17 @@ DEFINE_TEST(test_read_format_isorr_bz2)
const void *p;
size_t size;
off_t offset;
int r;
extract_reference_file(refname);
assert((a = archive_read_new()) != NULL);
assertEqualInt(0, archive_read_support_compression_all(a));
r = archive_read_support_compression_bzip2(a);
if (r == ARCHIVE_FATAL) {
skipping("Bzip2 decompression unsupported on this platform");
archive_read_finish(a);
return;
}
assertEqualInt(0, r);
assertEqualInt(0, archive_read_support_format_all(a));
assertEqualInt(0, archive_read_open_filename(a, refname, 10240));
@ -70,7 +77,7 @@ DEFINE_TEST(test_read_format_isorr_bz2)
assertEqualInt(0, archive_entry_uid(ae));
assertEqualIntA(a, ARCHIVE_EOF,
archive_read_data_block(a, &p, &size, &offset));
assertEqualInt(size, 0);
assertEqualInt((int)size, 0);
/* A directory. */
assertEqualInt(0, archive_read_next_header(a, &ae));
@ -89,7 +96,7 @@ DEFINE_TEST(test_read_format_isorr_bz2)
assert(S_ISREG(archive_entry_stat(ae)->st_mode));
assertEqualInt(6, archive_entry_size(ae));
assertEqualInt(0, archive_read_data_block(a, &p, &size, &offset));
assertEqualInt(6, size);
assertEqualInt(6, (int)size);
assertEqualInt(0, offset);
assertEqualInt(0, memcmp(p, "hello\n", 6));
assertEqualInt(86401, archive_entry_mtime(ae));

View file

@ -42,6 +42,7 @@ static unsigned char archive[] = {
DEFINE_TEST(test_read_format_pax_bz2)
{
#if HAVE_BZLIB_H
struct archive_entry *ae;
struct archive *a;
assert((a = archive_read_new()) != NULL);
@ -57,6 +58,9 @@ DEFINE_TEST(test_read_format_pax_bz2)
#else
assert(0 == archive_read_finish(a));
#endif
#else
skipping("Need bzlib");
#endif
}

View file

@ -35,6 +35,7 @@ static unsigned char archive[] = {
DEFINE_TEST(test_read_format_tbz)
{
#if HAVE_BZLIB_H
struct archive_entry *ae;
struct archive *a;
assert((a = archive_read_new()) != NULL);
@ -50,6 +51,9 @@ DEFINE_TEST(test_read_format_tbz)
#else
assert(0 == archive_read_finish(a));
#endif
#else
skipping("Need bzlib");
#endif
}

View file

@ -34,6 +34,7 @@ static unsigned char archive[] = {
DEFINE_TEST(test_read_format_tgz)
{
#if HAVE_ZLIB_H
struct archive_entry *ae;
struct archive *a;
assert((a = archive_read_new()) != NULL);
@ -49,6 +50,9 @@ DEFINE_TEST(test_read_format_tgz)
#else
assert(0 == archive_read_finish(a));
#endif
#else
skipping("Need zlib");
#endif
}

View file

@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
DEFINE_TEST(test_read_format_zip)
{
#if HAVE_ZLIB_H
const char *refname = "test_read_format_zip.zip";
struct archive_entry *ae;
struct archive *a;
@ -52,7 +53,7 @@ DEFINE_TEST(test_read_format_zip)
assertEqualInt(0, archive_entry_size(ae));
assertEqualIntA(a, ARCHIVE_EOF,
archive_read_data_block(a, &pv, &s, &o));
assertEqualInt(s, 0);
assertEqualInt((int)s, 0);
assertA(0 == archive_read_next_header(a, &ae));
assertEqualString("file1", archive_entry_pathname(ae));
assertEqualInt(1179604289, archive_entry_mtime(ae));
@ -77,6 +78,9 @@ DEFINE_TEST(test_read_format_zip)
#else
assert(0 == archive_read_finish(a));
#endif
#else
skipping("Need zlib");
#endif
}

View file

@ -34,7 +34,7 @@ DEFINE_TEST(test_read_large)
{
unsigned int i;
int tmpfilefd;
char tmpfilename[] = "/tmp/test-read_large.XXXXXX";
char tmpfilename[] = "test-read_large.XXXXXX";
size_t used;
struct archive *a;
struct archive_entry *entry;
@ -77,7 +77,7 @@ DEFINE_TEST(test_read_large)
assertA(0 == archive_read_support_compression_all(a));
assertA(0 == archive_read_open_memory(a, buff, sizeof(buff)));
assertA(0 == archive_read_next_header(a, &entry));
assert(0 < (tmpfilefd = mkstemp(tmpfilename)));
assert(0 < (tmpfilefd = open(tmpfilename, O_WRONLY | O_CREAT | O_BINARY, 0755)));
assertA(0 == archive_read_data_into_fd(a, tmpfilefd));
close(tmpfilefd);
#if ARCHIVE_VERSION_NUMBER < 2000000

View file

@ -100,7 +100,7 @@ memory_write(struct archive *a, void *_private, const void *buff, size_t size)
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;
private->last->filebytes += (off_t)size;
} else {
/* Yes, we're assuming the very first write is metadata. */
/* It's header or metadata, copy and save it. */
@ -117,7 +117,7 @@ memory_write(struct archive *a, void *_private, const void *buff, size_t size)
}
block->next = NULL;
}
return (size);
return ((long)size);
}
static ssize_t
@ -141,7 +141,7 @@ memory_read(struct archive *a, void *_private, const void **buff)
* passing blocks from the template data.
*/
if (private->filebytes > (off_t)filedatasize)
size = filedatasize;
size = (ssize_t)filedatasize;
else
size = (ssize_t)private->filebytes;
private->filebytes -= size;
@ -152,7 +152,7 @@ memory_read(struct archive *a, void *_private, const void **buff)
*/
block = private->first;
private->first = block->next;
size = block->size;
size = (ssize_t)block->size;
if (block->buff != NULL) {
private->buff = block->buff;
*buff = block->buff;
@ -220,7 +220,7 @@ DEFINE_TEST(test_tar_large)
struct archive *a;
off_t filesize, writesize;
filedatasize = 1 * MB;
filedatasize = (size_t)(1 * MB);
filedata = malloc(filedatasize);
memset(filedata, 0xAA, filedatasize);
memset(&memdata, 0, sizeof(memdata));
@ -236,7 +236,7 @@ DEFINE_TEST(test_tar_large)
/*
* Write a series of large files to it.
*/
for (i = 0; tests[i] > 0; i++) {
for (i = 0; tests[i] != 0; i++) {
assert((ae = archive_entry_new()) != NULL);
sprintf(namebuff, "file_%d", i);
archive_entry_copy_pathname(ae, namebuff);
@ -244,6 +244,7 @@ DEFINE_TEST(test_tar_large)
filesize = tests[i];
if (filesize < 0) {
archive_entry_free(ae);
skipping("32-bit off_t doesn't permit testing of very large files.");
return;
}
@ -256,7 +257,7 @@ DEFINE_TEST(test_tar_large)
* Write the actual data to the archive.
*/
while (filesize > 0) {
writesize = filedatasize;
writesize = (off_t)filedatasize;
if (writesize > filesize)
writesize = filesize;
assertA(writesize == archive_write_data(a, filedata, writesize));

View file

@ -43,7 +43,7 @@ test_filename(const char *prefix, int dlen, int flen)
if (prefix != NULL) {
strcpy(filename, prefix);
i = strlen(prefix);
i = (int)strlen(prefix);
}
if (dlen > 0) {
for (; i < dlen; i++)

View file

@ -88,7 +88,7 @@ DEFINE_TEST(test_write_compress)
if (!assertEqualInt(0, archive_read_next_header(a, &ae)))
break;
assertEqualString(path, archive_entry_pathname(ae));
assertEqualInt(datasize, archive_entry_size(ae));
assertEqualInt((int)datasize, archive_entry_size(ae));
}
assert(0 == archive_read_close(a));
#if ARCHIVE_VERSION_NUMBER < 2000000

View file

@ -37,12 +37,18 @@ DEFINE_TEST(test_write_compress_program)
struct archive *a;
size_t used;
int blocksize = 1024;
int r;
/* Create a new archive in memory. */
/* Write it through an external "gzip" program. */
assert((a = archive_write_new()) != NULL);
assertA(0 == archive_write_set_format_ustar(a));
assertA(0 == archive_write_set_compression_program(a, "gzip"));
r = archive_write_set_compression_program(a, "gzip");
if (r == ARCHIVE_FATAL) {
skipping("Write compression via external program unsupported on this platform");
archive_write_finish(a);
return;
}
assertA(0 == archive_write_set_bytes_per_block(a, blocksize));
assertA(0 == archive_write_set_bytes_in_last_block(a, blocksize));
assertA(blocksize == archive_write_get_bytes_in_last_block(a));

View file

@ -52,7 +52,9 @@ static void create(struct archive_entry *ae, const char *msg)
* that automatically. */
if (archive_entry_filetype(ae) == AE_IFDIR)
st.st_mode &= ~S_ISGID;
#ifndef _WIN32
assertEqualInt(st.st_mode, archive_entry_mode(ae) & ~UMASK);
#endif
}
static void create_reg_file(struct archive_entry *ae, const char *msg)
@ -97,8 +99,10 @@ static void create_reg_file(struct archive_entry *ae, const char *msg)
assert(0 == stat(archive_entry_pathname(ae), &st));
failure("st.st_mode=%o archive_entry_mode(ae)=%o",
st.st_mode, archive_entry_mode(ae));
#ifndef _WIN32
assertEqualInt(st.st_mode, (archive_entry_mode(ae) & ~UMASK));
assertEqualInt(st.st_size, sizeof(data));
#endif
assertEqualInt(st.st_size, sizeof(data));
/* test_write_disk_times has more detailed tests of this area. */
assertEqualInt(st.st_mtime, 123456789);
failure("No atime was specified, so atime should get set to current time");
@ -142,7 +146,9 @@ static void create_reg_file2(struct archive_entry *ae, const char *msg)
assert(0 == stat(archive_entry_pathname(ae), &st));
failure("st.st_mode=%o archive_entry_mode(ae)=%o",
st.st_mode, archive_entry_mode(ae));
#ifndef _WIN32
assertEqualInt(st.st_mode, (archive_entry_mode(ae) & ~UMASK));
#endif
assertEqualInt(st.st_size, i);
compare = malloc(datasize);
@ -177,7 +183,9 @@ static void create_reg_file3(struct archive_entry *ae, const char *msg)
assert(0 == stat(archive_entry_pathname(ae), &st));
failure("st.st_mode=%o archive_entry_mode(ae)=%o",
st.st_mode, archive_entry_mode(ae));
#ifndef _WIN32
assertEqualInt(st.st_mode, (archive_entry_mode(ae) & ~UMASK));
#endif
assertEqualInt(st.st_size, 5);
}
@ -204,7 +212,9 @@ static void create_reg_file4(struct archive_entry *ae, const char *msg)
assert(0 == stat(archive_entry_pathname(ae), &st));
failure("st.st_mode=%o archive_entry_mode(ae)=%o",
st.st_mode, archive_entry_mode(ae));
#ifndef _WIN32
assertEqualInt(st.st_mode, (archive_entry_mode(ae) & ~UMASK));
#endif
failure(msg);
assertEqualInt(st.st_size, sizeof(data));
}

View file

@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$");
*/
DEFINE_TEST(test_write_disk_hardlink)
{
#if ARCHIVE_VERSION_NUMBER < 1009000
#if ARCHIVE_VERSION_NUMBER < 1009000 || defined(_WIN32)
skipping("archive_write_disk_hardlink tests");
#else
static const char data[]="abcdefghijklmnopqrstuvwxyz";

View file

@ -25,7 +25,7 @@
#include "test.h"
__FBSDID("$FreeBSD$");
#if ARCHIVE_VERSION_NUMBER >= 1009000
#if ARCHIVE_VERSION_NUMBER >= 1009000 && !defined(_WIN32)
#define UMASK 022
@ -125,7 +125,7 @@ defaultgid(void)
DEFINE_TEST(test_write_disk_perms)
{
#if ARCHIVE_VERSION_NUMBER < 1009000
#if ARCHIVE_VERSION_NUMBER < 1009000 || defined(_WIN32)
skipping("archive_write_disk interface");
#else
struct archive *a;

View file

@ -55,6 +55,7 @@ DEFINE_TEST(test_write_disk_secure)
archive_entry_free(ae);
assert(0 == archive_write_finish_entry(a));
#ifndef _WIN32
/* Write a symlink to the dir above. */
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, "link_to_dir");
@ -149,6 +150,7 @@ DEFINE_TEST(test_write_disk_secure)
assertEqualInt(0, lstat("link_to_dir4", &st));
assert(S_ISDIR(st.st_mode));
archive_entry_free(ae);
#endif
/*
* As above, but a link to a non-dir, so the link should get replaced.
@ -185,6 +187,7 @@ DEFINE_TEST(test_write_disk_secure)
assert(0 == archive_write_finish(a));
#endif
#ifndef _WIN32
/* Test the entries on disk. */
assert(0 == lstat("dir", &st));
failure("dir: st.st_mode=%o", st.st_mode);
@ -217,4 +220,5 @@ DEFINE_TEST(test_write_disk_secure)
failure("link_to_dir2/filec: st.st_mode=%o", st.st_mode);
assert((st.st_mode & 07777) == 0755);
#endif
#endif
}

View file

@ -46,7 +46,6 @@ DEFINE_TEST(test_write_format_ar)
*/
assert((a = archive_write_new()) != NULL);
assertA(0 == archive_write_set_format_ar_svr4(a));
assertA(0 == archive_write_set_compression_gzip(a));
assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used));
/* write the filename table */
@ -153,7 +152,6 @@ DEFINE_TEST(test_write_format_ar)
memset(buff, 0, sizeof(buff));
assert((a = archive_write_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ar_bsd(a));
assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_bzip2(a));
assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, sizeof(buff), &used));
/* write a entry need long name extension */

View file

@ -205,7 +205,7 @@ DEFINE_TEST(test_write_format_cpio_newc)
assertEqualMem(e + 121, "\0\0\0", 3); /* Pad to multiple of 4 bytes */
e += 124; /* Must be multiple of four here! */
assertEqualInt(used, e - buff);
assertEqualInt((int)used, e - buff);
free(buff);
}

View file

@ -218,7 +218,7 @@ DEFINE_TEST(test_write_format_cpio_odc)
assertEqualMem(e + 76, "TRAILER!!!\0", 11); /* Name */
e += 87;
assertEqualInt(used, e - buff);
assertEqualInt((int)used, e - buff);
free(buff);
}

View file

@ -42,8 +42,8 @@ DEFINE_TEST(test_write_format_tar)
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_set_bytes_per_block(a, blocksize));
assertA(0 == archive_write_set_bytes_in_last_block(a, blocksize));
assertA(0 == archive_write_set_bytes_per_block(a, (int)blocksize));
assertA(0 == archive_write_set_bytes_in_last_block(a, (int)blocksize));
assertA(blocksize == (size_t)archive_write_get_bytes_in_last_block(a));
assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used));
assertA(blocksize == (size_t)archive_write_get_bytes_in_last_block(a));

View file

@ -83,7 +83,7 @@ DEFINE_TEST(test_write_format_tar_empty)
/* Earlier versions wrote 0-length files for empty tar archives. */
skipping("empty tar archive size");
#else
assertEqualInt(used, 1024);
assertEqualInt((int)used, 1024);
#endif
for (i = 0; i < used; i++) {
failure("Empty tar archive should be all nulls.");

View file

@ -340,7 +340,7 @@ DEFINE_TEST(test_write_format_tar_ustar)
assert(is_null(e, 1024));
e += 1024;
assertEqualInt(used, e - buff);
assertEqualInt((int)used, e - buff);
free(buff);
}

View file

@ -50,7 +50,7 @@ DEFINE_TEST(test_write_open_memory)
assert((a = archive_write_new()) != NULL);
assertA(0 == archive_write_set_format_ustar(a));
assertA(0 == archive_write_set_bytes_in_last_block(a, 1));
assertA(0 == archive_write_set_bytes_per_block(a, blocksize));
assertA(0 == archive_write_set_bytes_per_block(a, (int)blocksize));
buff[i] = 0xAE;
assertA(0 == archive_write_open_memory(a, buff, i, &s));
/* If buffer is smaller than a tar header, this should fail. */