Index: dist/cat/test/test_0.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/cat/test/test_0.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -p -r1.1.1.1 -r1.2 --- dist/cat/test/test_0.c 20 Apr 2017 12:55:31 -0000 1.1.1.1 +++ dist/cat/test/test_0.c 21 Jan 2020 18:33:47 -0000 1.2 @@ -59,7 +59,7 @@ DEFINE_TEST(test_0) * we know some option that will succeed. */ if (0 != systemf("%s --version >" DEV_NULL, testprog)) { - failure("Unable to successfully run: %s --version\n", testprog, testprog); + failure("Unable to successfully run: %s --version\n", testprog); assert(0); } Index: dist/cpio/test/test_basic.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/cpio/test/test_basic.c,v retrieving revision 1.1.1.4 retrieving revision 1.2 diff -u -p -r1.1.1.4 -r1.2 --- dist/cpio/test/test_basic.c 24 Jul 2019 13:50:21 -0000 1.1.1.4 +++ dist/cpio/test/test_basic.c 21 Jan 2020 18:33:47 -0000 1.2 @@ -33,15 +33,15 @@ verify_files(const char *msg) */ /* Regular file with 2 links. */ - failure(msg); + failure("%s", msg); assertIsReg("file", 0644); - failure(msg); + failure("%s", msg); assertFileSize("file", 10); - failure(msg); + failure("%s", msg); assertFileNLinks("file", 2); /* Another name for the same file. */ - failure(msg); + failure("%s", msg); assertIsHardlink("linkfile", "file"); /* Symlink */ @@ -49,11 +49,11 @@ verify_files(const char *msg) assertIsSymlink("symlink", "file", 0); /* Another file with 1 link and different permissions. */ - failure(msg); + failure("%s", msg); assertIsReg("file2", 0777); - failure(msg); + failure("%s", msg); assertFileSize("file2", 10); - failure(msg); + failure("%s", msg); assertFileNLinks("file2", 1); /* dir */ Index: dist/cpio/test/test_format_newc.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/cpio/test/test_format_newc.c,v retrieving revision 1.1.1.4 retrieving revision 1.3 diff -u -p -r1.1.1.4 -r1.3 --- dist/cpio/test/test_format_newc.c 24 Jul 2019 13:50:21 -0000 1.1.1.4 +++ dist/cpio/test/test_format_newc.c 27 Feb 2020 10:32:35 -0000 1.3 @@ -49,10 +49,11 @@ is_hex(const char *p, size_t l) return (1); } -static int +/* Convert up to 8 hex characters to unsigned 32-bit decimal integer */ +static uint32_t from_hex(const char *p, size_t l) { - int r = 0; + uint32_t r = 0; while (l > 0) { r *= 16; @@ -82,11 +83,11 @@ DEFINE_TEST(test_format_newc) { FILE *list; int r; - int devmajor, devminor, ino, gid; - int uid = -1; + uint32_t devmajor, devminor, ino, gid, uid; time_t t, t2, now; char *p, *e; - size_t s, fs, ns; + size_t s; + uint64_t fs, ns; char result[1024]; assertUmask(0); @@ -199,28 +200,32 @@ DEFINE_TEST(test_format_newc) #else assertEqualInt(0x81a4, from_hex(e + 14, 8)); /* Mode */ #endif - if (uid < 0) - uid = from_hex(e + 22, 8); +#if defined(_WIN32) + uid = from_hex(e + 22, 8); +#else assertEqualInt(from_hex(e + 22, 8), uid); /* uid */ +#endif gid = from_hex(e + 30, 8); /* gid */ assertEqualMem(e + 38, "00000003", 8); /* nlink */ t = from_hex(e + 46, 8); /* mtime */ - failure("t=0x%08x now=0x%08x=%d", t, now, now); + failure("t=%#08jx now=%#08jx=%jd", (intmax_t)t, (intmax_t)now, + (intmax_t)now); assert(t <= now); /* File wasn't created in future. */ - failure("t=0x%08x now - 2=0x%08x = %d", t, now - 2, now - 2); + failure("t=%#08jx now - 2=%#08jx=%jd", (intmax_t)t, (intmax_t)now - 2, + (intmax_t)now - 2); assert(t >= now - 2); /* File was created w/in last 2 secs. */ failure("newc format stores body only with last appearance of a link\n" " first appearance should be empty, so this file size\n" " field should be zero"); assertEqualInt(0, from_hex(e + 54, 8)); /* File size */ - fs = from_hex(e + 54, 8); + fs = (uint64_t)from_hex(e + 54, 8); fs += PAD(fs, 4); devmajor = from_hex(e + 62, 8); /* devmajor */ devminor = from_hex(e + 70, 8); /* devminor */ assert(is_hex(e + 78, 8)); /* rdevmajor */ assert(is_hex(e + 86, 8)); /* rdevminor */ assertEqualMem(e + 94, "00000006", 8); /* Name size */ - ns = from_hex(e + 94, 8); + ns = (uint64_t)from_hex(e + 94, 8); ns += PAD(ns + 2, 4); assertEqualInt(0, from_hex(e + 102, 8)); /* check field */ assertEqualMem(e + 110, "file1\0", 6); /* Name contents */ @@ -243,17 +248,18 @@ DEFINE_TEST(test_format_newc) assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */ assertEqualMem(e + 38, "00000001", 8); /* nlink */ t2 = from_hex(e + 46, 8); /* mtime */ - failure("First entry created at t=0x%08x this entry created at t2=0x%08x", t, t2); + failure("First entry created at t=%#08jx this entry created" + " at t2=%#08jx", (intmax_t)t, (intmax_t)t2); assert(t2 == t || t2 == t + 1); /* Almost same as first entry. */ assertEqualMem(e + 54, "00000005", 8); /* File size */ - fs = from_hex(e + 54, 8); + fs = (uint64_t)from_hex(e + 54, 8); fs += PAD(fs, 4); assertEqualInt(devmajor, from_hex(e + 62, 8)); /* devmajor */ assertEqualInt(devminor, from_hex(e + 70, 8)); /* devminor */ assert(is_hex(e + 78, 8)); /* rdevmajor */ assert(is_hex(e + 86, 8)); /* rdevminor */ assertEqualMem(e + 94, "00000008", 8); /* Name size */ - ns = from_hex(e + 94, 8); + ns = (uint64_t)from_hex(e + 94, 8); ns += PAD(ns + 2, 4); assertEqualInt(0, from_hex(e + 102, 8)); /* check field */ assertEqualMem(e + 110, "symlink\0\0\0", 10); /* Name contents */ @@ -278,17 +284,18 @@ DEFINE_TEST(test_format_newc) assertEqualInt(nlinks("dir"), from_hex(e + 38, 8)); /* nlinks */ #endif t2 = from_hex(e + 46, 8); /* mtime */ - failure("First entry created at t=0x%08x this entry created at t2=0x%08x", t, t2); + failure("First entry created at t=%#08jx this entry created at" + "t2=%#08jx", (intmax_t)t, (intmax_t)t2); assert(t2 == t || t2 == t + 1); /* Almost same as first entry. */ assertEqualMem(e + 54, "00000000", 8); /* File size */ - fs = from_hex(e + 54, 8); + fs = (uint64_t)from_hex(e + 54, 8); fs += PAD(fs, 4); assertEqualInt(devmajor, from_hex(e + 62, 8)); /* devmajor */ assertEqualInt(devminor, from_hex(e + 70, 8)); /* devminor */ assert(is_hex(e + 78, 8)); /* rdevmajor */ assert(is_hex(e + 86, 8)); /* rdevminor */ assertEqualMem(e + 94, "00000004", 8); /* Name size */ - ns = from_hex(e + 94, 8); + ns = (uint64_t)from_hex(e + 94, 8); ns += PAD(ns + 2, 4); assertEqualInt(0, from_hex(e + 102, 8)); /* check field */ assertEqualMem(e + 110, "dir\0\0\0", 6); /* Name contents */ @@ -311,17 +318,18 @@ DEFINE_TEST(test_format_newc) assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */ assertEqualMem(e + 38, "00000003", 8); /* nlink */ t2 = from_hex(e + 46, 8); /* mtime */ - failure("First entry created at t=0x%08x this entry created at t2=0x%08x", t, t2); + failure("First entry created at t=%#08jx this entry created at" + "t2=%#08jx", (intmax_t)t, (intmax_t)t2); assert(t2 == t || t2 == t + 1); /* Almost same as first entry. */ assertEqualInt(10, from_hex(e + 54, 8)); /* File size */ - fs = from_hex(e + 54, 8); + fs = (uint64_t)from_hex(e + 54, 8); fs += PAD(fs, 4); assertEqualInt(devmajor, from_hex(e + 62, 8)); /* devmajor */ assertEqualInt(devminor, from_hex(e + 70, 8)); /* devminor */ assert(is_hex(e + 78, 8)); /* rdevmajor */ assert(is_hex(e + 86, 8)); /* rdevminor */ assertEqualMem(e + 94, "00000009", 8); /* Name size */ - ns = from_hex(e + 94, 8); + ns = (uint64_t)from_hex(e + 94, 8); ns += PAD(ns + 2, 4); assertEqualInt(0, from_hex(e + 102, 8)); /* check field */ assertEqualMem(e + 110, "hardlink\0\0", 10); /* Name contents */ Index: dist/libarchive/archive_read.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/archive_read.c,v retrieving revision 1.1.1.4 retrieving revision 1.2 diff -u -p -r1.1.1.4 -r1.2 --- dist/libarchive/archive_read.c 24 Jul 2019 13:50:24 -0000 1.1.1.4 +++ dist/libarchive/archive_read.c 25 Feb 2020 09:01:25 -0000 1.2 @@ -891,15 +891,16 @@ archive_read_data(struct archive *_a, vo len = a->read_data_remaining; if (len > s) len = s; - if (len) + if (len) { memcpy(dest, a->read_data_block, len); - s -= len; - a->read_data_block += len; - a->read_data_remaining -= len; - a->read_data_output_offset += len; - a->read_data_offset += len; - dest += len; - bytes_read += len; + s -= len; + a->read_data_block += len; + a->read_data_remaining -= len; + a->read_data_output_offset += len; + a->read_data_offset += len; + dest += len; + bytes_read += len; + } } } a->read_data_is_posix_read = 0; Index: dist/libarchive/archive_read_disk_posix.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/archive_read_disk_posix.c,v retrieving revision 1.1.1.2 retrieving revision 1.2 diff -u -p -r1.1.1.2 -r1.2 --- dist/libarchive/archive_read_disk_posix.c 24 Jul 2019 13:50:23 -0000 1.1.1.2 +++ dist/libarchive/archive_read_disk_posix.c 29 Mar 2021 15:31:46 -0000 1.2 @@ -1527,6 +1527,15 @@ get_xfer_size(struct tree *t, int fd, co #if defined(HAVE_STATFS) && defined(HAVE_FSTATFS) && defined(MNT_LOCAL) \ && !defined(ST_LOCAL) +static void +set_transfer_size(struct filesystem *fs, const struct statfs *sfs) +{ + fs->xfer_align = sfs->f_bsize > 0 ? (long)sfs->fs_bsize : -1; + fs->max_xfer_size = -1; + fs->min_xfer_size = sfs->f_iosize > 0 ? (long)sfs->f_iosize : -1; + fs->incr_xfer_size = sfs->f_iosize > 0 ? (long)sfs->f_iosize : -1; +} + /* * Gather current filesystem properties on FreeBSD, OpenBSD and Mac OS X. */ @@ -1595,10 +1604,7 @@ setup_current_filesystem(struct archive_ return (ARCHIVE_FAILED); } else if (xr == 1) { /* pathconf(_PC_REX_*) operations are not supported. */ - t->current_filesystem->xfer_align = sfs.f_bsize; - t->current_filesystem->max_xfer_size = -1; - t->current_filesystem->min_xfer_size = sfs.f_iosize; - t->current_filesystem->incr_xfer_size = sfs.f_iosize; + set_transfer_size(t->current_filesystem, &sfs); } if (sfs.f_flags & MNT_LOCAL) t->current_filesystem->remote = 0; @@ -1653,6 +1659,20 @@ setup_current_filesystem(struct archive_ #elif (defined(HAVE_STATVFS) || defined(HAVE_FSTATVFS)) && defined(ST_LOCAL) +static void +set_transfer_size(struct filesystem *fs, const struct statvfs *sfs) +{ + fs->xfer_align = sfs->f_frsize > 0 ? (long)sfs->f_frsize : -1; + fs->max_xfer_size = -1; +#if defined(HAVE_STRUCT_STATVFS_F_IOSIZE) + fs->min_xfer_size = sfs->f_iosize > 0 ? (long)sfs->f_iosize : -1; + fs->incr_xfer_size = sfs->f_iosize > 0 ? (long)sfs->f_iosize : -1; +#else + fs->min_xfer_size = sfs->f_bsize > 0 : (long)sfs->f_bsize : -1; + fs->incr_xfer_size = sfs->f_bsize > 0 : (long)sfs->f_bsize : -1; +#endif +} + /* * Gather current filesystem properties on NetBSD */ @@ -1690,15 +1710,7 @@ setup_current_filesystem(struct archive_ } else if (xr == 1) { /* Usually come here unless NetBSD supports _PC_REC_XFER_ALIGN * for pathconf() function. */ - t->current_filesystem->xfer_align = sfs.f_frsize; - t->current_filesystem->max_xfer_size = -1; -#if defined(HAVE_STRUCT_STATVFS_F_IOSIZE) - t->current_filesystem->min_xfer_size = sfs.f_iosize; - t->current_filesystem->incr_xfer_size = sfs.f_iosize; -#else - t->current_filesystem->min_xfer_size = sfs.f_bsize; - t->current_filesystem->incr_xfer_size = sfs.f_bsize; -#endif + set_transfer_size(t->current_filesystem, &sfs); } if (sfs.f_flag & ST_LOCAL) t->current_filesystem->remote = 0; @@ -1805,15 +1817,9 @@ setup_current_filesystem(struct archive_ } else if (xr == 1) { /* pathconf(_PC_REX_*) operations are not supported. */ #if defined(HAVE_STATVFS) - t->current_filesystem->xfer_align = svfs.f_frsize; - t->current_filesystem->max_xfer_size = -1; - t->current_filesystem->min_xfer_size = svfs.f_bsize; - t->current_filesystem->incr_xfer_size = svfs.f_bsize; + set_transfer_size(t->current_filesystem, &svfs); #else - t->current_filesystem->xfer_align = sfs.f_frsize; - t->current_filesystem->max_xfer_size = -1; - t->current_filesystem->min_xfer_size = sfs.f_bsize; - t->current_filesystem->incr_xfer_size = sfs.f_bsize; + set_transfer_size(t->current_filesystem, &sfs); #endif } switch (sfs.f_type) { @@ -1920,10 +1926,7 @@ setup_current_filesystem(struct archive_ return (ARCHIVE_FAILED); } else if (xr == 1) { /* pathconf(_PC_REX_*) operations are not supported. */ - t->current_filesystem->xfer_align = sfs.f_frsize; - t->current_filesystem->max_xfer_size = -1; - t->current_filesystem->min_xfer_size = sfs.f_bsize; - t->current_filesystem->incr_xfer_size = sfs.f_bsize; + set_transfer_size(t->current_filesystem, &sfs); } #if defined(ST_NOATIME) Index: dist/libarchive/archive_read_open_filename.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/archive_read_open_filename.c,v retrieving revision 1.1.1.4 retrieving revision 1.2 diff -u -p -r1.1.1.4 -r1.2 --- dist/libarchive/archive_read_open_filename.c 20 Apr 2017 12:55:36 -0000 1.1.1.4 +++ dist/libarchive/archive_read_open_filename.c 5 Sep 2020 13:35:24 -0000 1.2 @@ -221,7 +221,9 @@ file_open(struct archive *a, void *clien struct read_file_data *mine = (struct read_file_data *)client_data; void *buffer; const char *filename = NULL; +#if defined(_WIN32) && !defined(__CYGWIN__) const wchar_t *wfilename = NULL; +#endif int fd = -1; int is_disk_like = 0; #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) @@ -281,10 +283,12 @@ file_open(struct archive *a, void *clien #endif } if (fstat(fd, &st) != 0) { +#if defined(_WIN32) && !defined(__CYGWIN__) if (mine->filename_type == FNT_WCS) archive_set_error(a, errno, "Can't stat '%S'", wfilename); else +#endif archive_set_error(a, errno, "Can't stat '%s'", filename); goto fail; Index: dist/libarchive/archive_read_support_format_xar.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/archive_read_support_format_xar.c,v retrieving revision 1.1.1.4 retrieving revision 1.2 diff -u -p -r1.1.1.4 -r1.2 --- dist/libarchive/archive_read_support_format_xar.c 24 Jul 2019 13:50:22 -0000 1.1.1.4 +++ dist/libarchive/archive_read_support_format_xar.c 27 Feb 2020 10:35:08 -0000 1.2 @@ -458,6 +458,11 @@ archive_read_support_format_xar(struct a return (ARCHIVE_FATAL); } + /* initialize xar->file_queue */ + xar->file_queue.allocated = 0; + xar->file_queue.used = 0; + xar->file_queue.files = NULL; + r = __archive_read_register_format(a, xar, "xar", @@ -1221,10 +1226,12 @@ heap_add_entry(struct archive_read *a, /* Expand our pending files list as necessary. */ if (heap->used >= heap->allocated) { struct xar_file **new_pending_files; - int new_size = heap->allocated * 2; + int new_size; if (heap->allocated < 1024) new_size = 1024; + else + new_size = heap->allocated * 2; /* Overflow might keep us from growing the list. */ if (new_size <= heap->allocated) { archive_set_error(&a->archive, @@ -1238,9 +1245,11 @@ heap_add_entry(struct archive_read *a, ENOMEM, "Out of memory"); return (ARCHIVE_FATAL); } - memcpy(new_pending_files, heap->files, - heap->allocated * sizeof(new_pending_files[0])); - free(heap->files); + if (heap->allocated) { + memcpy(new_pending_files, heap->files, + heap->allocated * sizeof(new_pending_files[0])); + free(heap->files); + } heap->files = new_pending_files; heap->allocated = new_size; } Index: dist/libarchive/archive_write_disk_posix.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/archive_write_disk_posix.c,v retrieving revision 1.1.1.2.2.2 retrieving revision 1.6 diff -u -p -r1.1.1.2.2.2 -r1.6 --- dist/libarchive/archive_write_disk_posix.c 10 Feb 2020 19:30:00 -0000 1.1.1.2.2.2 +++ dist/libarchive/archive_write_disk_posix.c 14 Aug 2020 14:42:44 -0000 1.6 @@ -2184,8 +2184,11 @@ restore_entry(struct archive_write_disk if ((a->flags & ARCHIVE_EXTRACT_ATOMIC) && S_ISREG(a->st.st_mode)) { /* Use a temporary file to extract */ - if ((a->fd = la_mktemp(a)) == -1) + if ((a->fd = la_mktemp(a)) == -1) { + archive_set_error(&a->archive, en, + "Can't create '%s'", a->name); return ARCHIVE_FAILED; + } a->pst = NULL; en = 0; } else { Index: dist/libarchive/test/test_acl_platform_nfs4.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_acl_platform_nfs4.c,v retrieving revision 1.1.1.2 retrieving revision 1.2 diff -u -p -r1.1.1.2 -r1.2 --- dist/libarchive/test/test_acl_platform_nfs4.c 24 Jul 2019 13:50:38 -0000 1.1.1.2 +++ dist/libarchive/test/test_acl_platform_nfs4.c 22 Apr 2020 15:55:55 -0000 1.2 @@ -634,9 +634,11 @@ acl_match(acl_entry_t aclent, struct mya case ACL_ENTRY_TYPE_AUDIT: if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_AUDIT) return (0); + break; case ACL_ENTRY_TYPE_ALARM: if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_ALARM) return (0); + break; default: return (0); } Index: dist/libarchive/test/test_acl_platform_posix1e.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_acl_platform_posix1e.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -p -r1.1.1.1 -r1.2 --- dist/libarchive/test/test_acl_platform_posix1e.c 20 Apr 2017 12:55:53 -0000 1.1.1.1 +++ dist/libarchive/test/test_acl_platform_posix1e.c 22 Apr 2020 15:55:41 -0000 1.2 @@ -364,8 +364,8 @@ DEFINE_TEST(test_acl_platform_posix1e_re struct archive *a; struct archive_entry *ae; int n, fd, flags, dflags; - char *func, *acl_text; - const char *acl1_text, *acl2_text, *acl3_text; + char *acl_text; + const char *func, *acl1_text, *acl2_text, *acl3_text; #if ARCHIVE_ACL_SUNOS void *aclp; int aclcnt; Index: dist/libarchive/test/test_compat_zip.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_compat_zip.c,v retrieving revision 1.1.1.4 retrieving revision 1.2 diff -u -p -r1.1.1.4 -r1.2 --- dist/libarchive/test/test_compat_zip.c 24 Jul 2019 13:50:24 -0000 1.1.1.4 +++ dist/libarchive/test/test_compat_zip.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -156,7 +156,7 @@ DEFINE_TEST(test_compat_zip_4) size_t s; extract_reference_file(refname); - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); /* SFX files require seek support. */ assert((a = archive_read_new()) != NULL); @@ -214,7 +214,7 @@ DEFINE_TEST(test_compat_zip_5) size_t s; extract_reference_file(refname); - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); /* Verify with seek support. * Everything works correctly here. */ @@ -370,7 +370,7 @@ DEFINE_TEST(test_compat_zip_6) size_t s; extract_reference_file(refname); - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); assert((a = archive_read_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); @@ -402,7 +402,7 @@ DEFINE_TEST(test_compat_zip_7) int i; extract_reference_file(refname); - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); for (i = 1; i < 1000; ++i) { assert((a = archive_read_new()) != NULL); @@ -436,7 +436,7 @@ DEFINE_TEST(test_compat_zip_8) size_t s; extract_reference_file(refname); - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); assert((a = archive_read_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); Index: dist/libarchive/test/test_fuzz.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_fuzz.c,v retrieving revision 1.1.1.3 retrieving revision 1.2 diff -u -p -r1.1.1.3 -r1.2 --- dist/libarchive/test/test_fuzz.c 24 Jul 2019 13:50:24 -0000 1.1.1.3 +++ dist/libarchive/test/test_fuzz.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -119,7 +119,8 @@ test_fuzz(const struct files *filesets) for (i = 0; filesets[n].names[i] != NULL; ++i) { char *newraw; - tmp = slurpfile(&size, filesets[n].names[i]); + tmp = slurpfile(&size, "%s", + filesets[n].names[i]); newraw = realloc(rawimage, oldsize + size); if (!assert(newraw != NULL)) { Index: dist/libarchive/test/test_read_extract.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_read_extract.c,v retrieving revision 1.1.1.4 retrieving revision 1.2 diff -u -p -r1.1.1.4 -r1.2 --- dist/libarchive/test/test_read_extract.c 24 Jul 2019 13:50:37 -0000 1.1.1.4 +++ dist/libarchive/test/test_read_extract.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -120,7 +120,7 @@ DEFINE_TEST(test_read_extract) assertA(0 == archive_read_support_filter_all(a)); assertA(0 == archive_read_open_memory(a, buff, BUFF_SIZE)); /* Restore first entry with _EXTRACT_PERM. */ - failure("Error reading first entry", i); + failure("Error reading first entry"); assertA(0 == archive_read_next_header(a, &ae)); assertA(0 == archive_read_extract(a, ae, ARCHIVE_EXTRACT_PERM)); /* Rest of entries get restored with no flags. */ Index: dist/libarchive/test/test_read_format_gtar_sparse.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_read_format_gtar_sparse.c,v retrieving revision 1.1.1.3 retrieving revision 1.2 diff -u -p -r1.1.1.3 -r1.2 --- dist/libarchive/test/test_read_format_gtar_sparse.c 20 Apr 2017 12:55:48 -0000 1.1.1.3 +++ dist/libarchive/test/test_read_format_gtar_sparse.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -214,8 +214,9 @@ verify_archive_file(const char *name, st * Any byte before the expected * data must be NULL. */ - failure("%s: pad at offset %d " - "should be zero", name, actual.o); + failure("%s: pad at offset %jd " + "should be zero", name, + (intmax_t)actual.o); assertEqualInt(c, 0); } else if (actual.o == expect.o) { /* Index: dist/libarchive/test/test_read_format_zip.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_read_format_zip.c,v retrieving revision 1.1.1.4 retrieving revision 1.2 diff -u -p -r1.1.1.4 -r1.2 --- dist/libarchive/test/test_read_format_zip.c 24 Jul 2019 13:50:37 -0000 1.1.1.4 +++ dist/libarchive/test/test_read_format_zip.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -194,7 +194,7 @@ test_basic(void) verify_basic(a, 1); /* Verify with streaming reader. */ - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); assert((a = archive_read_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); @@ -264,7 +264,7 @@ test_info_zip_ux(void) verify_info_zip_ux(a, 1); /* Verify with streaming reader. */ - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); assert((a = archive_read_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); @@ -328,7 +328,7 @@ test_extract_length_at_end(void) verify_extract_length_at_end(a, 1); /* Verify extraction with streaming reader. */ - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); assert((a = archive_read_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); @@ -347,7 +347,7 @@ test_symlink(void) struct archive_entry *ae; extract_reference_file(refname); - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); /* Symlinks can only be extracted with the seeking reader. */ assert((a = archive_read_new()) != NULL); Index: dist/libarchive/test/test_read_format_zip_7075_utf8_paths.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_read_format_zip_7075_utf8_paths.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -p -r1.1.1.1 -r1.2 --- dist/libarchive/test/test_read_format_zip_7075_utf8_paths.c 24 Jul 2019 13:50:38 -0000 1.1.1.1 +++ dist/libarchive/test/test_read_format_zip_7075_utf8_paths.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -90,7 +90,7 @@ DEFINE_TEST(test_read_format_zip_utf8_pa assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); /* Verify with streaming reader. */ - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); assert((a = archive_read_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); Index: dist/libarchive/test/test_read_format_zip_comment_stored.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_read_format_zip_comment_stored.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -p -r1.1.1.1 -r1.2 --- dist/libarchive/test/test_read_format_zip_comment_stored.c 20 Apr 2017 12:55:51 -0000 1.1.1.1 +++ dist/libarchive/test/test_read_format_zip_comment_stored.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -38,7 +38,7 @@ verify(const char *refname) struct archive_entry *ae; extract_reference_file(refname); - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); /* Symlinks can only be extracted with the seeking reader. */ assert((a = archive_read_new()) != NULL); Index: dist/libarchive/test/test_read_format_zip_extra_padding.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_read_format_zip_extra_padding.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -p -r1.1.1.1 -r1.2 --- dist/libarchive/test/test_read_format_zip_extra_padding.c 24 Jul 2019 13:50:38 -0000 1.1.1.1 +++ dist/libarchive/test/test_read_format_zip_extra_padding.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -80,7 +80,7 @@ DEFINE_TEST(test_read_format_zip_extra_p assertEqualInt(ARCHIVE_OK, archive_read_free(a)); /* Verify with streaming reader. */ - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); assert((a = archive_read_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); Index: dist/libarchive/test/test_read_format_zip_high_compression.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_read_format_zip_high_compression.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -p -r1.1.1.1 -r1.2 --- dist/libarchive/test/test_read_format_zip_high_compression.c 20 Apr 2017 12:55:37 -0000 1.1.1.1 +++ dist/libarchive/test/test_read_format_zip_high_compression.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -56,7 +56,7 @@ DEFINE_TEST(test_read_format_zip_high_co } extract_reference_file(refname); - p = slurpfile(&archive_size, refname); + p = slurpfile(&archive_size, "%s", refname); assert((a = archive_read_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a)); Index: dist/libarchive/test/test_read_format_zip_jar.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_read_format_zip_jar.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -p -r1.1.1.1 -r1.2 --- dist/libarchive/test/test_read_format_zip_jar.c 20 Apr 2017 12:55:56 -0000 1.1.1.1 +++ dist/libarchive/test/test_read_format_zip_jar.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -40,7 +40,7 @@ DEFINE_TEST(test_read_format_zip_jar) char data[16]; extract_reference_file(refname); - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); assert((a = archive_read_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip_seekable(a)); Index: dist/libarchive/test/test_read_format_zip_mac_metadata.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_read_format_zip_mac_metadata.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -p -r1.1.1.1 -r1.2 --- dist/libarchive/test/test_read_format_zip_mac_metadata.c 20 Apr 2017 12:55:53 -0000 1.1.1.1 +++ dist/libarchive/test/test_read_format_zip_mac_metadata.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -76,7 +76,7 @@ DEFINE_TEST(test_read_format_zip_mac_met }; extract_reference_file(refname); - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); /* Mac metadata can only be extracted with the seeking reader. */ assert((a = archive_read_new()) != NULL); Index: dist/libarchive/test/test_read_format_zip_malformed.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_read_format_zip_malformed.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -p -r1.1.1.1 -r1.2 --- dist/libarchive/test/test_read_format_zip_malformed.c 20 Apr 2017 12:55:38 -0000 1.1.1.1 +++ dist/libarchive/test/test_read_format_zip_malformed.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -46,7 +46,7 @@ test_malformed1(void) assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a)); /* Verify with streaming reader. */ - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); assert((a = archive_read_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); Index: dist/libarchive/test/test_read_format_zip_msdos.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_read_format_zip_msdos.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -p -r1.1.1.1 -r1.2 --- dist/libarchive/test/test_read_format_zip_msdos.c 20 Apr 2017 12:55:53 -0000 1.1.1.1 +++ dist/libarchive/test/test_read_format_zip_msdos.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -103,7 +103,7 @@ DEFINE_TEST(test_read_format_zip_msdos) assertEqualInt(ARCHIVE_OK, archive_read_free(a)); /* Verify with streaming reader. */ - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); assert((a = archive_read_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); Index: dist/libarchive/test/test_read_format_zip_nested.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_read_format_zip_nested.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -p -r1.1.1.1 -r1.2 --- dist/libarchive/test/test_read_format_zip_nested.c 20 Apr 2017 12:55:40 -0000 1.1.1.1 +++ dist/libarchive/test/test_read_format_zip_nested.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -34,7 +34,7 @@ DEFINE_TEST(test_read_format_zip_nested) struct archive_entry *ae; extract_reference_file(refname); - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); /* Inspect outer Zip */ assert((a = archive_read_new()) != NULL); Index: dist/libarchive/test/test_read_format_zip_nofiletype.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_read_format_zip_nofiletype.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -p -r1.1.1.1 -r1.2 --- dist/libarchive/test/test_read_format_zip_nofiletype.c 20 Apr 2017 12:55:38 -0000 1.1.1.1 +++ dist/libarchive/test/test_read_format_zip_nofiletype.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -40,7 +40,7 @@ DEFINE_TEST(test_read_format_zip_nofilet char data[16]; extract_reference_file(refname); - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); assert((a = archive_read_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip_seekable(a)); Index: dist/libarchive/test/test_read_format_zip_padded.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_read_format_zip_padded.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -p -r1.1.1.1 -r1.2 --- dist/libarchive/test/test_read_format_zip_padded.c 20 Apr 2017 12:55:49 -0000 1.1.1.1 +++ dist/libarchive/test/test_read_format_zip_padded.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -34,7 +34,7 @@ verify_padded_archive(const char *refnam struct archive_entry *ae; extract_reference_file(refname); - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); assert((a = archive_read_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip_seekable(a)); Index: dist/libarchive/test/test_read_format_zip_sfx.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_read_format_zip_sfx.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -p -r1.1.1.1 -r1.2 --- dist/libarchive/test/test_read_format_zip_sfx.c 20 Apr 2017 12:55:55 -0000 1.1.1.1 +++ dist/libarchive/test/test_read_format_zip_sfx.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -37,7 +37,7 @@ DEFINE_TEST(test_read_format_zip_sfx) struct archive_entry *ae; extract_reference_file(refname); - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); /* Symlinks can only be extracted with the seeking reader. */ assert((a = archive_read_new()) != NULL); Index: dist/libarchive/test/test_read_format_zip_with_invalid_traditional_eocd.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_read_format_zip_with_invalid_traditional_eocd.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -p -r1.1.1.1 -r1.2 --- dist/libarchive/test/test_read_format_zip_with_invalid_traditional_eocd.c 20 Apr 2017 12:55:48 -0000 1.1.1.1 +++ dist/libarchive/test/test_read_format_zip_with_invalid_traditional_eocd.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -39,7 +39,7 @@ DEFINE_TEST(test_read_format_zip_with_in struct archive_entry *ae; extract_reference_file(refname); - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); assert((a = archive_read_new()) != NULL); assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip_seekable(a)); Index: dist/libarchive/test/test_read_format_zip_zip64.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_read_format_zip_zip64.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -p -r1.1.1.1 -r1.2 --- dist/libarchive/test/test_read_format_zip_zip64.c 20 Apr 2017 12:55:51 -0000 1.1.1.1 +++ dist/libarchive/test/test_read_format_zip_zip64.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -88,7 +88,7 @@ DEFINE_TEST(test_read_format_zip_zip64a) size_t s; extract_reference_file(refname); - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); /* First read with seeking. */ assert((a = archive_read_new()) != NULL); @@ -112,7 +112,7 @@ DEFINE_TEST(test_read_format_zip_zip64b) size_t s; extract_reference_file(refname); - p = slurpfile(&s, refname); + p = slurpfile(&s, "%s", refname); /* First read with seeking. */ assert((a = archive_read_new()) != NULL); Index: dist/libarchive/test/test_read_pax_truncated.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_read_pax_truncated.c,v retrieving revision 1.1.1.3 retrieving revision 1.2 diff -u -p -r1.1.1.3 -r1.2 --- dist/libarchive/test/test_read_pax_truncated.c 20 Apr 2017 12:55:49 -0000 1.1.1.3 +++ dist/libarchive/test/test_read_pax_truncated.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -82,7 +82,7 @@ DEFINE_TEST(test_read_pax_truncated) assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae)); goto wrap_up; } else { - failure("Archive truncated to %d bytes", i); + failure("Archive truncated to %zu bytes", i); assertEqualIntA(a, 0, archive_read_next_header(a, &ae)); } @@ -91,7 +91,7 @@ DEFINE_TEST(test_read_pax_truncated) assertEqualIntA(a, ARCHIVE_FATAL, archive_read_data(a, filedata, filedata_size)); goto wrap_up; } else { - failure("Archive truncated to %d bytes", i); + failure("Archive truncated to %zu bytes", i); assertEqualIntA(a, filedata_size, archive_read_data(a, filedata, filedata_size)); } @@ -103,7 +103,7 @@ DEFINE_TEST(test_read_pax_truncated) * does not return an error if it can't consume * it.) */ if (i < 1536 + 512*((filedata_size + 511)/512) + 512) { - failure("i=%d minsize=%d", i, + failure("i=%zu minsize=%zu", i, 1536 + 512*((filedata_size + 511)/512) + 512); assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae)); Index: dist/libarchive/test/test_read_truncated_filter.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_read_truncated_filter.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -p -r1.1.1.1 -r1.2 --- dist/libarchive/test/test_read_truncated_filter.c 20 Apr 2017 12:55:37 -0000 1.1.1.1 +++ dist/libarchive/test/test_read_truncated_filter.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -83,7 +83,7 @@ test_truncation(const char *compression, for (i = 0; i < 100; i++) { sprintf(path, "%s%d", compression, i); archive_entry_copy_pathname(ae, path); - failure(path); + failure("%s", path); if (!assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae))) { archive_write_free(a); @@ -94,7 +94,7 @@ test_truncation(const char *compression, for (j = 0; j < (int)datasize; ++j) { data[j] = (char)(rand() % 256); } - failure(path); + failure("%s", path); if (!assertEqualIntA(a, datasize, archive_write_data(a, data, datasize))) { archive_write_free(a); Index: dist/libarchive/test/test_sparse_basic.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_sparse_basic.c,v retrieving revision 1.1.1.2.2.1 retrieving revision 1.3 diff -u -p -r1.1.1.2.2.1 -r1.3 --- dist/libarchive/test/test_sparse_basic.c 21 Jan 2020 15:48:52 -0000 1.1.1.2.2.1 +++ dist/libarchive/test/test_sparse_basic.c 21 Jan 2020 18:33:48 -0000 1.3 @@ -430,7 +430,7 @@ verify_sparse_file(struct archive *a, co assert(sparse->type == END); assertEqualInt(expected_offset, archive_entry_size(ae)); - failure(path); + failure("%s", path); assertEqualInt(holes_seen, expected_holes); assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a)); @@ -466,7 +466,7 @@ verify_sparse_file2(struct archive *a, c /* Verify the number of holes only, not its offset nor its * length because those alignments are deeply dependence on * its filesystem. */ - failure(path); + failure("%s", path); assertEqualInt(blocks, archive_entry_sparse_count(ae)); archive_entry_free(ae); } Index: dist/libarchive/test/test_write_disk.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_write_disk.c,v retrieving revision 1.1.1.3 retrieving revision 1.2 diff -u -p -r1.1.1.3 -r1.2 --- dist/libarchive/test/test_write_disk.c 20 Apr 2017 12:55:49 -0000 1.1.1.3 +++ dist/libarchive/test/test_write_disk.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -186,7 +186,7 @@ static void create_reg_file4(struct arch #if !defined(_WIN32) || defined(__CYGWIN__) assertEqualInt(st.st_mode, (archive_entry_mode(ae) & ~UMASK)); #endif - failure(msg); + failure("%s", msg); assertEqualInt(st.st_size, sizeof(data)); } Index: dist/libarchive/test/test_write_disk_secure.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_write_disk_secure.c,v retrieving revision 1.1.1.3.14.1 retrieving revision 1.4 diff -u -p -r1.1.1.3.14.1 -r1.4 --- dist/libarchive/test/test_write_disk_secure.c 21 Jan 2020 15:48:52 -0000 1.1.1.3.14.1 +++ dist/libarchive/test/test_write_disk_secure.c 28 Aug 2020 18:44:54 -0000 1.4 @@ -40,6 +40,16 @@ DEFINE_TEST(test_write_disk_secure) struct archive *a; struct archive_entry *ae; struct stat st; + char tmp[2048]; + const char *tmpdir; + const char *lname = + "libarchive_test-test_write_disk_secure-absolute_symlink"; +#if 0 + const char *fname = + "libarchive_test-test_write_disk_secure-absolute_symlink_path.tmp"; +#endif + const char *pname = + "libarchive_test-test_write_disk_secure-absolute_path.tmp"; /* Start with a known umask. */ assertUmask(UMASK); @@ -86,12 +96,15 @@ DEFINE_TEST(test_write_disk_secure) assert(0 == archive_write_finish_entry(a)); #endif - /* Write an absolute symlink to /tmp. */ + /* Write an absolute symlink to $TMPDIR. */ archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS); assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "/tmp/libarchive_test-test_write_disk_secure-absolute_symlink"); + if ((tmpdir = getenv("TMPDIR")) == NULL) + tmpdir = "/tmp"; + snprintf(tmp, sizeof(tmp), "%s/%s", tmpdir, lname); + archive_entry_copy_pathname(ae, tmp); archive_entry_set_mode(ae, S_IFLNK | 0777); - archive_entry_set_symlink(ae, "/tmp"); + archive_entry_set_symlink(ae, tmpdir); archive_write_disk_set_options(a, 0); assert(0 == archive_write_header(a, ae)); assert(0 == archive_write_finish_entry(a)); @@ -99,15 +112,18 @@ DEFINE_TEST(test_write_disk_secure) #if 0 /* With security checks enabled, this should fail. */ assert(archive_entry_clear(ae) != NULL); - archive_entry_copy_pathname(ae, "/tmp/libarchive_test-test_write_disk_secure-absolute_symlink/libarchive_test-test_write_disk_secure-absolute_symlink_path.tmp"); + snprintf(tmp, sizeof(tmp), "%s/%s/%s", tmpdir, lname, fname); + archive_entry_copy_pathname(ae, tmp); archive_entry_set_mode(ae, S_IFREG | 0777); archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS); failure("Extracting a file through an absolute symlink should fail here."); assertEqualInt(ARCHIVE_FAILED, archive_write_header(a, ae)); archive_entry_free(ae); - assertFileNotExists("/tmp/libarchive_test-test_write_disk_secure-absolute_symlink/libarchive_test-test_write_disk_secure-absolute_symlink_path.tmp"); - assert(0 == unlink("/tmp/libarchive_test-test_write_disk_secure-absolute_symlink")); - unlink("/tmp/libarchive_test-test_write_disk_secure-absolute_symlink_path.tmp"); + assertFileNotExists(tmp); + snprintf(tmp, sizeof(tmp), "%s/%s", tmpdir, lname); + assert(0 == unlink(tmp)); + snprintf(tmp, sizeof(tmp), "%s/%s", tmpdir, fname); + unlink(tmp); #endif /* Create another link. */ @@ -230,23 +246,24 @@ DEFINE_TEST(test_write_disk_secure) * extract an absolute path. */ assert((ae = archive_entry_new()) != NULL); - archive_entry_copy_pathname(ae, "/tmp/libarchive_test-test_write_disk_secure-absolute_path.tmp"); + snprintf(tmp, sizeof(tmp), "%s/%s", tmpdir, pname); + archive_entry_copy_pathname(ae, tmp); archive_entry_set_mode(ae, S_IFREG | 0777); assert(0 == archive_write_header(a, ae)); assert(0 == archive_write_finish_entry(a)); - assertFileExists("/tmp/libarchive_test-test_write_disk_secure-absolute_path.tmp"); - assert(0 == unlink("/tmp/libarchive_test-test_write_disk_secure-absolute_path.tmp")); + assertFileExists(tmp); + assert(0 == unlink(tmp)); /* But with security checks enabled, this should fail. */ assert(archive_entry_clear(ae) != NULL); - archive_entry_copy_pathname(ae, "/tmp/libarchive_test-test_write_disk_secure-absolute_path.tmp"); + archive_entry_copy_pathname(ae, tmp); archive_entry_set_mode(ae, S_IFREG | 0777); archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS); failure("Extracting an absolute path should fail here."); assertEqualInt(ARCHIVE_FAILED, archive_write_header(a, ae)); archive_entry_free(ae); assert(0 == archive_write_finish_entry(a)); - assertFileNotExists("/tmp/libarchive_test-test_write_disk_secure-absolute_path.tmp"); + assertFileNotExists(tmp); assertEqualInt(ARCHIVE_OK, archive_write_free(a)); Index: dist/libarchive/test/test_write_format_cpio_empty.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_write_format_cpio_empty.c,v retrieving revision 1.1.1.3 retrieving revision 1.2 diff -u -p -r1.1.1.3 -r1.2 --- dist/libarchive/test/test_write_format_cpio_empty.c 20 Apr 2017 12:55:48 -0000 1.1.1.3 +++ dist/libarchive/test/test_write_format_cpio_empty.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -64,7 +64,7 @@ DEFINE_TEST(test_write_format_cpio_empty assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a)); assertEqualInt(ARCHIVE_OK, archive_write_free(a)); - failure("Empty cpio archive should be exactly 87 bytes, was %d.", used); + failure("Empty cpio archive should be exactly 87 bytes, was %zu.", used); assert(used == 87); failure("Empty cpio archive is incorrectly formatted."); assertEqualMem(buff, ref, 87); Index: dist/libarchive/test/test_write_format_shar_empty.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_write_format_shar_empty.c,v retrieving revision 1.1.1.3 retrieving revision 1.2 diff -u -p -r1.1.1.3 -r1.2 --- dist/libarchive/test/test_write_format_shar_empty.c 20 Apr 2017 12:55:39 -0000 1.1.1.3 +++ dist/libarchive/test/test_write_format_shar_empty.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -49,6 +49,6 @@ DEFINE_TEST(test_write_format_shar_empty assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a)); assertEqualInt(ARCHIVE_OK, archive_write_free(a)); - failure("Empty shar archive should be exactly 0 bytes, was %d.", used); + failure("Empty shar archive should be exactly 0 bytes, was %zu.", used); assert(used == 0); } Index: dist/libarchive/test/test_write_format_tar.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_write_format_tar.c,v retrieving revision 1.1.1.3 retrieving revision 1.2 diff -u -p -r1.1.1.3 -r1.2 --- dist/libarchive/test/test_write_format_tar.c 20 Apr 2017 12:55:52 -0000 1.1.1.3 +++ dist/libarchive/test/test_write_format_tar.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -81,7 +81,7 @@ DEFINE_TEST(test_write_format_tar) /* This calculation gives "the smallest multiple of * the block size that is at least 2048 bytes". */ - failure("blocksize=%d", blocksize); + failure("blocksize=%zu", blocksize); assertEqualInt(((2048 - 1)/blocksize+1)*blocksize, used); /* Index: dist/libarchive/test/test_write_format_tar_sparse.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/libarchive/test/test_write_format_tar_sparse.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -p -r1.1.1.1 -r1.2 --- dist/libarchive/test/test_write_format_tar_sparse.c 20 Apr 2017 12:55:52 -0000 1.1.1.1 +++ dist/libarchive/test/test_write_format_tar_sparse.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -94,7 +94,7 @@ test_1(void) /* This calculation gives "the smallest multiple of * the block size that is at least 11264 bytes". */ - failure("blocksize=%d", blocksize); + failure("blocksize=%zu", blocksize); assertEqualInt(((11264 - 1)/blocksize+1)*blocksize, used); /* @@ -229,7 +229,7 @@ test_2(void) /* This calculation gives "the smallest multiple of * the block size that is at least 11264 bytes". */ - failure("blocksize=%d", blocksize); + failure("blocksize=%zu", blocksize); assertEqualInt(((11264 - 1)/blocksize+1)*blocksize, used); /* Index: dist/tar/write.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/tar/write.c,v retrieving revision 1.1.1.5 retrieving revision 1.3 diff -u -p -r1.1.1.5 -r1.3 --- dist/tar/write.c 24 Jul 2019 13:50:41 -0000 1.1.1.5 +++ dist/tar/write.c 28 Jan 2021 19:46:54 -0000 1.3 @@ -798,7 +798,9 @@ copy_file_data_block(struct bsdtar *bsdt progress += bytes_written; } if (r < ARCHIVE_WARN) { - lafe_warnc(archive_errno(a), "%s", archive_error_string(a)); + const char *s = archive_error_string(a); + if (s) + lafe_warnc(archive_errno(a), "%s", s); return (-1); } return (0); @@ -971,16 +973,15 @@ write_entry(struct bsdtar *bsdtar, struc e = archive_write_header(a, entry); if (e != ARCHIVE_OK) { - if (bsdtar->verbose > 1) { + if (bsdtar->verbose > 0) { safe_fprintf(stderr, "a "); list_item_verbose(bsdtar, stderr, entry); lafe_warnc(0, ": %s", archive_error_string(a)); - } else if (bsdtar->verbose > 0) { + } else { lafe_warnc(0, "%s: %s", archive_entry_pathname(entry), archive_error_string(a)); - } else - fprintf(stderr, ": %s", archive_error_string(a)); + } } if (e == ARCHIVE_FATAL) Index: dist/tar/test/test_basic.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/tar/test/test_basic.c,v retrieving revision 1.1.1.4 retrieving revision 1.2 diff -u -p -r1.1.1.4 -r1.2 --- dist/tar/test/test_basic.c 24 Jul 2019 13:50:41 -0000 1.1.1.4 +++ dist/tar/test/test_basic.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -96,7 +96,7 @@ run_tar(const char *target, const char * /* Use the tar program to create an archive. */ r = systemf("%s cf - %s %s >%s/archive 2>%s/pack.err", testprog, pack_options, flist, target, target); - failure("Error invoking %s cf -", testprog, pack_options); + failure("Error invoking %s cf -%s", testprog, pack_options); assertEqualInt(r, 0); assertChdir(target); Index: dist/tar/test/test_copy.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/tar/test/test_copy.c,v retrieving revision 1.1.1.4.2.1 retrieving revision 1.3 diff -u -p -r1.1.1.4.2.1 -r1.3 --- dist/tar/test/test_copy.c 21 Jan 2020 15:48:52 -0000 1.1.1.4.2.1 +++ dist/tar/test/test_copy.c 21 Jan 2020 18:33:48 -0000 1.3 @@ -256,13 +256,13 @@ verify_tree(size_t limit) continue; switch(dp[0]) { case 'l': case 'm': case 'd': - failure("strlen(p)=%d", strlen(p)); + failure("strlen(p)=%zu", strlen(p)); assert(strlen(p) < limit); assertEqualString(p, filenames[strlen(p)]); break; case 'f': case 's': - failure("strlen(p)=%d", strlen(p)); + failure("strlen(p)=%zu", strlen(p)); assert(strlen(p) < limit + 1); assertEqualString(p, filenames[strlen(p)]); Index: dist/tar/test/test_option_C_upper.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/tar/test/test_option_C_upper.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -p -r1.1.1.1 -r1.2 --- dist/tar/test/test_option_C_upper.c 20 Apr 2017 12:55:32 -0000 1.1.1.1 +++ dist/tar/test/test_option_C_upper.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -117,7 +117,7 @@ DEFINE_TEST(test_option_C_upper) assertMakeDir("test6", 0755); assertChdir("test6"); r = systemf("%s -cf archive.tar -C XXX -C ../d1 file1 2>write.err", - testprog, testworkdir); + testprog); assert(r != 0); assertNonEmptyFile("write.err"); assertEqualInt(0, Index: dist/tar/test/test_option_s.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/tar/test/test_option_s.c,v retrieving revision 1.1.1.3 retrieving revision 1.2 diff -u -p -r1.1.1.3 -r1.2 --- dist/tar/test/test_option_s.c 24 Jul 2019 13:50:41 -0000 1.1.1.3 +++ dist/tar/test/test_option_s.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -92,10 +92,8 @@ DEFINE_TEST(test_option_s) * Test 5: Name-switching substitutions when extracting archive. */ assertMakeDir("test5", 0755); - systemf("%s -cf test5.tar in/d1/foo in/d1/bar", - testprog, testprog); - systemf("%s -xf test5.tar -s /foo/bar/ -s }bar}foo} -C test5", - testprog, testprog); + systemf("%s -cf test5.tar in/d1/foo in/d1/bar", testprog); + systemf("%s -xf test5.tar -s /foo/bar/ -s }bar}foo} -C test5", testprog); assertFileContents("foo", 3, "test5/in/d1/bar"); assertFileContents("bar", 3, "test5/in/d1/foo"); Index: dist/test_utils/test_common.h =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/test_utils/test_common.h,v retrieving revision 1.1.2.2 retrieving revision 1.2 diff -u -p -r1.1.2.2 -r1.2 --- dist/test_utils/test_common.h 21 Jan 2020 15:48:52 -0000 1.1.2.2 +++ dist/test_utils/test_common.h 21 Jan 2020 18:33:48 -0000 1.2 @@ -115,6 +115,13 @@ #pragma warn -8068 /* Constant out of range in comparison. */ #endif +#if defined(__GNUC__) && (__GNUC__ > 2 || \ + (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) +#define __LA_PRINTFLIKE(f,a) __attribute__((__format__(__printf__, f, a))) +#else +#define __LA_PRINTFLIKE(f,a) +#endif + /* Haiku OS and QNX */ #if defined(__HAIKU__) || defined(__QNXNTO__) /* Haiku and QNX have typedefs in stdint.h (needed for int64_t) */ @@ -266,7 +273,7 @@ skipping_setup(__FILE__, __LINE__);test_skipping /* Function declarations. These are defined in test_utility.c. */ -void failure(const char *fmt, ...); +void failure(const char *fmt, ...) __LA_PRINTFLIKE(1, 2); int assertion_assert(const char *, int, int, const char *, void *); int assertion_chdir(const char *, int, const char *); int assertion_compare_fflags(const char *, int, const char *, const char *, @@ -309,10 +316,10 @@ int assertion_utimes(const char *, int, int assertion_version(const char*, int, const char *, const char *); void skipping_setup(const char *, int); -void test_skipping(const char *fmt, ...); +void test_skipping(const char *fmt, ...) __LA_PRINTFLIKE(1, 2); /* Like sprintf, then system() */ -int systemf(const char * fmt, ...); +int systemf(const char *fmt, ...) __LA_PRINTFLIKE(1, 2); /* Delay until time() returns a value after this. */ void sleepUntilAfter(time_t); @@ -375,7 +382,7 @@ void *sunacl_get(int cmd, int *aclcnt, i /* 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, ...); +char *slurpfile(size_t *, const char *fmt, ...) __LA_PRINTFLIKE(2, 3); /* Dump block of bytes to a file. */ void dumpfile(const char *filename, void *, size_t); Index: dist/test_utils/test_main.c =================================================================== RCS file: /cvsroot/src/external/bsd/libarchive/dist/test_utils/test_main.c,v retrieving revision 1.1.2.2 retrieving revision 1.2 diff -u -p -r1.1.2.2 -r1.2 --- dist/test_utils/test_main.c 21 Jan 2020 15:48:52 -0000 1.1.2.2 +++ dist/test_utils/test_main.c 21 Jan 2020 18:33:48 -0000 1.2 @@ -388,7 +388,7 @@ static const char *refdir; */ static int log_console = 0; static FILE *logfile; -static void +static void __LA_PRINTFLIKE(1, 0) vlogprintf(const char *fmt, va_list ap) { #ifdef va_copy @@ -406,7 +406,7 @@ vlogprintf(const char *fmt, va_list ap) #endif } -static void +static void __LA_PRINTFLIKE(1, 2) logprintf(const char *fmt, ...) { va_list ap; @@ -478,7 +478,7 @@ static struct line { const char *failed_filename; /* Count this failure, setup up log destination and handle initial report. */ -static void +static void __LA_PRINTFLIKE(3, 4) failure_start(const char *filename, int line, const char *fmt, ...) { va_list ap; @@ -751,7 +751,7 @@ static void strdump(const char *e, const logprintf("]"); logprintf(" (count %d", cnt); if (n < 0) { - logprintf(",unknown %d bytes", len); + logprintf(",unknown %zu bytes", len); } logprintf(")"); @@ -1167,7 +1167,7 @@ assertion_text_file_contents(const char logprintf(" file=\"%s\"\n", fn); if (n > 0) { hexdump(contents, buff, n, 0); - logprintf(" expected\n", fn); + logprintf(" expected\n"); hexdump(buff, contents, s, 0); } else { logprintf(" File empty, contents should be:\n"); @@ -1497,7 +1497,7 @@ assertion_file_time(const char *file, in } } else if (filet != t || filet_nsec != nsec) { failure_start(file, line, - "File %s has %ctime %lld.%09lld, expected %lld.%09lld", + "File %s has %ctime %lld.%09lld, expected %ld.%09ld", pathname, type, filet, filet_nsec, t, nsec); failure_finish(NULL); return (0); @@ -3271,7 +3271,7 @@ assertion_entry_set_acls(const char *fil acls[i].qual, acls[i].name); if (r != 0) { ret = 1; - failure_start(file, line, "type=%#010x, ", + failure_start(file, line, "type=%#010x, " "permset=%#010x, tag=%d, qual=%d name=%s", acls[i].type, acls[i].permset, acls[i].tag, acls[i].qual, acls[i].name);