git: 2dddbb67c6a1 - stable/14 - libarchive: merge from vendor branch
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 23 Apr 2026 09:44:51 UTC
The branch stable/14 has been updated by mm:
URL: https://cgit.FreeBSD.org/src/commit/?id=2dddbb67c6a15317df549538be286e908d11de98
commit 2dddbb67c6a15317df549538be286e908d11de98
Author: Martin Matuska <mm@FreeBSD.org>
AuthorDate: 2026-04-13 13:47:17 +0000
Commit: Martin Matuska <mm@FreeBSD.org>
CommitDate: 2026-04-23 09:44:04 +0000
libarchive: merge from vendor branch
libarchive 3.8.7
Important bugfixes:
#2871 libarchive: fix handling of option failures
#2897 iso9660: fix undefined behavior
#2898 RAR: fix LZSS window size mismatch after PPMd block
#2900 CAB: fix NULL pointer dereference during skip
#2911 libarchive: do not continue with truncated numbers
#2919 CAB: Fix Heap OOB Write in CAB LZX decoder
#2934 iso9660: fix posibble heap buffer overflow on 32-bit systems
#2939 cpio: Fix -R memory leak
#2947 libarchive: lzop and grzip filter support
Important bugfixes between 3.8.5 and 3.8.6:
#2860 bsdunzip: fix ISO week year and Gregorian year confusion
#2864 7zip: ix SEGV in check_7zip_header_in_sfx via ELF offset validation
#2875 7zip: fix out-of-bounds access on ELF 64-bit header
#2877 RAR5 reader: fix infinite loop in rar5 decompression
#2878 mtree reader: Fix file descriptor leak in mtree parser cleanup
(CWE-775)
#2892 RAR5 reader: fix potential memory leak
#2893 RAR5: fix SIGSEGV when archive_read_support_format_rar5 is called
twice
#2895 CAB reader: fix memory leak on repeated calls to
archive_read_support_format_cab
Obtained from: libarchive
Vendor commit: ded82291ab41d5e355831b96b0e1ff49e24d8939
MFC after: 1 week
(cherry picked from commit eb5165bb491138f60d9004bc4c781490016d9288)
---
contrib/libarchive/NEWS | 4 +
contrib/libarchive/README.md | 9 +-
contrib/libarchive/cpio/cmdline.c | 15 +-
contrib/libarchive/cpio/cpio.c | 123 ++-
contrib/libarchive/cpio/cpio.h | 2 -
contrib/libarchive/cpio/test/test_format_newc.c | 7 +
contrib/libarchive/libarchive/archive.h | 4 +-
contrib/libarchive/libarchive/archive_acl.c | 6 +-
.../libarchive/libarchive/archive_check_magic.c | 4 +-
.../libarchive/archive_cryptor_private.h | 4 +
contrib/libarchive/libarchive/archive_entry.h | 2 +-
contrib/libarchive/libarchive/archive_hmac.c | 6 +
contrib/libarchive/libarchive/archive_options.c | 4 +-
contrib/libarchive/libarchive/archive_pathmatch.c | 4 +-
contrib/libarchive/libarchive/archive_ppmd8.c | 22 +-
.../libarchive/libarchive/archive_ppmd8_private.h | 25 -
contrib/libarchive/libarchive/archive_read.c | 12 +-
.../libarchive/archive_read_append_filter.c | 4 +
.../libarchive/archive_read_disk_posix.c | 6 +-
.../libarchive/archive_read_open_filename.c | 7 +-
.../libarchive/archive_read_support_filter_grzip.c | 2 +-
.../libarchive/archive_read_support_filter_lz4.c | 4 +-
.../libarchive/archive_read_support_filter_lzop.c | 2 +-
.../archive_read_support_filter_program.c | 2 +
.../libarchive/archive_read_support_format_7zip.c | 24 +-
.../libarchive/archive_read_support_format_cab.c | 24 +-
.../libarchive/archive_read_support_format_cpio.c | 4 +-
.../archive_read_support_format_iso9660.c | 26 +-
.../libarchive/archive_read_support_format_lha.c | 11 +-
.../libarchive/archive_read_support_format_mtree.c | 7 +-
.../libarchive/archive_read_support_format_rar.c | 73 +-
.../libarchive/archive_read_support_format_rar5.c | 45 +-
.../libarchive/archive_read_support_format_tar.c | 6 +-
.../libarchive/archive_read_support_format_xar.c | 14 +-
.../libarchive/archive_read_support_format_zip.c | 22 +-
contrib/libarchive/libarchive/archive_string.c | 16 +-
contrib/libarchive/libarchive/archive_write.c | 2 +-
.../archive_write_add_filter_b64encode.c | 22 +-
.../libarchive/archive_write_add_filter_bzip2.c | 7 +-
.../libarchive/archive_write_add_filter_gzip.c | 12 +-
.../libarchive/archive_write_add_filter_lrzip.c | 21 +-
.../libarchive/archive_write_add_filter_lz4.c | 14 +-
.../libarchive/archive_write_add_filter_lzop.c | 7 +-
.../libarchive/archive_write_add_filter_uuencode.c | 22 +-
.../libarchive/archive_write_add_filter_xz.c | 27 +-
.../libarchive/archive_write_add_filter_zstd.c | 52 +-
.../libarchive/archive_write_disk_posix.c | 30 +-
.../libarchive/archive_write_set_format_7zip.c | 9 +-
.../archive_write_set_format_cpio_binary.c | 4 +-
.../archive_write_set_format_cpio_newc.c | 2 +-
.../libarchive/archive_write_set_format_cpio_odc.c | 2 +-
.../libarchive/archive_write_set_format_gnutar.c | 34 +-
.../libarchive/archive_write_set_format_iso9660.c | 18 +-
.../libarchive/archive_write_set_format_mtree.c | 2 +-
.../libarchive/archive_write_set_format_pax.c | 6 +-
.../libarchive/archive_write_set_format_ustar.c | 27 +-
.../libarchive/archive_write_set_format_v7tar.c | 27 +-
.../libarchive/archive_write_set_format_xar.c | 6 +-
.../libarchive/archive_write_set_format_zip.c | 49 +-
contrib/libarchive/libarchive/test/test_acl_text.c | 23 +
.../libarchive/test/test_archive_pathmatch.c | 18 +
.../test/test_archive_string_conversion.c | 135 +++
.../test/test_gnutar_filename_encoding.c | 40 +
.../libarchive/test/test_read_format_7zip.c | 26 +
.../test/test_read_format_7zip_malformed.c | 17 +
.../test/test_read_format_7zip_malformed3.7z.uu | 24 +
.../test_read_format_7zip_sfx_elf64trunc.elf.uu | 5 +
.../libarchive/test/test_read_format_cab_lzx_oob.c | 45 +
.../test/test_read_format_cab_lzx_oob.cab.uu | 11 +
.../test/test_read_format_cab_skip_malformed.c | 41 +
.../test_read_format_cab_skip_malformed.cab.uu | 95 ++
.../test/test_read_format_iso_zisofs_overflow.c | 104 ++
.../test_read_format_iso_zisofs_overflow.iso.uu | 1096 ++++++++++++++++++++
.../test/test_read_format_lha_oversize_header.c | 50 +
.../test_read_format_lha_oversize_header.lzh.uu | 60 ++
.../test/test_read_format_rar5_loop_bug.c | 53 +
.../test/test_read_format_rar5_loop_bug.rar.uu | 189 ++++
.../libarchive/test/test_read_set_format.c | 34 +
.../libarchive/test/test_ustar_filename_encoding.c | 40 +
.../libarchive/test/test_v7tar_filename_encoding.c | 67 ++
.../test/test_warn_missing_hardlink_target.c | 2 +-
.../libarchive/libarchive/test/test_write_disk.c | 29 +
.../libarchive/test/test_write_disk_perms.c | 11 +-
.../libarchive/test/test_zip_filename_encoding.c | 40 +
.../la_getline.c => libarchive_fe/lafe_getline.c} | 11 +-
.../la_getline.h => libarchive_fe/lafe_getline.h} | 15 +-
contrib/libarchive/tar/bsdtar.c | 20 +-
contrib/libarchive/tar/read.c | 2 +-
contrib/libarchive/tar/util.c | 8 +-
contrib/libarchive/tar/write.c | 16 +-
contrib/libarchive/test_utils/test_common.h | 4 +
contrib/libarchive/test_utils/test_main.c | 85 +-
contrib/libarchive/unzip/bsdunzip.c | 6 +-
lib/libarchive/tests/Makefile | 13 +
usr.bin/unzip/Makefile | 2 +-
95 files changed, 3019 insertions(+), 372 deletions(-)
diff --git a/contrib/libarchive/NEWS b/contrib/libarchive/NEWS
index be14de445b57..d5e9769771e2 100644
--- a/contrib/libarchive/NEWS
+++ b/contrib/libarchive/NEWS
@@ -1,3 +1,7 @@
+Apr 13, 2026: libarchive 3.8.7 released
+
+Mar 10, 2026: libarchive 3.8.6 released
+
Jan 05, 2026: libarchive 3.8.5 released
Dec 01, 2025: libarchive 3.8.4 released
diff --git a/contrib/libarchive/README.md b/contrib/libarchive/README.md
index e9691f1b710b..3009e1b54d18 100644
--- a/contrib/libarchive/README.md
+++ b/contrib/libarchive/README.md
@@ -37,10 +37,13 @@ The top-level directory contains the following information files:
* **CMakeLists.txt** - input for "cmake" build tool, see INSTALL
* **configure** - configuration script, see INSTALL for details. If your copy of the source lacks a `configure` script, you can try to construct it by running the script in `build/autogen.sh` (or use `cmake`).
-The following files in the top-level directory are used by the 'configure' script:
+The following files in the top-level directory are related to the 'configure' script and are only needed by maintainers:
-* `Makefile.am`, `aclocal.m4`, `configure.ac` - used to build this distribution, only needed by maintainers
-* `Makefile.in`, `config.h.in` - templates used by configure script
+* `configure.ac` - used (by autoconf) to build the configure script and related files
+* `Makefile.am` - used (by automake) to generate Makefile.in
+* `aclocal.m4` - auto-generated file (created by aclocal) used to build the configure script
+* `Makefile.in` - auto-generated template (created by automake) used by the configure script to create Makefile
+* `config.h.in` - auto-generated template (created by autoheader) used by the configure script to create config.h
## Documentation
diff --git a/contrib/libarchive/cpio/cmdline.c b/contrib/libarchive/cpio/cmdline.c
index db06c03c011d..a3d029c65161 100644
--- a/contrib/libarchive/cpio/cmdline.c
+++ b/contrib/libarchive/cpio/cmdline.c
@@ -11,6 +11,9 @@
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
#ifdef HAVE_GRP_H
#include <grp.h>
#endif
@@ -347,9 +350,10 @@ owner_parse(const char *spec, struct cpio_owner *owner, const char **errmsg)
owner->gid = pwent->pw_gid;
} else {
char *end;
+ unsigned long val;
errno = 0;
- owner->uid = (int)strtoul(user, &end, 10);
- if (errno || *end != '\0') {
+ val = strtoul(user, &end, 10);
+ if (errno || *end != '\0' || val > (unsigned)INT_MAX) {
snprintf(errbuff, sizeof(errbuff),
"Couldn't lookup user ``%s''", user);
errbuff[sizeof(errbuff) - 1] = '\0';
@@ -357,6 +361,7 @@ owner_parse(const char *spec, struct cpio_owner *owner, const char **errmsg)
*errmsg = errbuff;
return (-1);
}
+ owner->uid = (int)val;
}
free(user);
}
@@ -373,15 +378,17 @@ owner_parse(const char *spec, struct cpio_owner *owner, const char **errmsg)
}
} else {
char *end;
+ unsigned long val;
errno = 0;
- owner->gid = (int)strtoul(g, &end, 10);
- if (errno || *end != '\0') {
+ val = strtoul(g, &end, 10);
+ if (errno || *end != '\0' || val > (unsigned)INT_MAX) {
snprintf(errbuff, sizeof(errbuff),
"Couldn't lookup group ``%s''", g);
errbuff[sizeof(errbuff) - 1] = '\0';
*errmsg = errbuff;
return (-1);
}
+ owner->gid = (int)val;
}
}
return (0);
diff --git a/contrib/libarchive/cpio/cpio.c b/contrib/libarchive/cpio/cpio.c
index 77eefe809f37..6e6c2c3356c0 100644
--- a/contrib/libarchive/cpio/cpio.c
+++ b/contrib/libarchive/cpio/cpio.c
@@ -8,6 +8,8 @@
#include "cpio_platform.h"
+#include "lafe_getline.h"
+
#include <sys/types.h>
#include <archive.h>
#include <archive_entry.h>
@@ -33,6 +35,9 @@
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
@@ -83,7 +88,7 @@ struct name_cache {
static int extract_data(struct archive *, struct archive *);
const char * cpio_i64toa(int64_t);
-static const char *cpio_rename(const char *name);
+static void cpio_rename(struct archive_entry *);
static int entry_to_archive(struct cpio *, struct archive_entry *);
static int file_to_archive(struct cpio *, const char *);
static void free_cache(struct name_cache *cache);
@@ -110,19 +115,16 @@ static void passphrase_free(char *);
int
main(int argc, char *argv[])
{
- static char buff[16384];
struct cpio _cpio; /* Allocated on stack. */
struct cpio *cpio;
struct cpio_owner owner;
const char *errmsg;
char *tptr;
- int opt, t;
+ int opt;
+ long t;
cpio = &_cpio;
memset(cpio, 0, sizeof(*cpio));
- cpio->buff = buff;
- cpio->buff_size = sizeof(buff);
-
#if defined(HAVE_SIGACTION)
{
@@ -204,13 +206,13 @@ main(int argc, char *argv[])
case 'C': /* NetBSD/OpenBSD */
errno = 0;
tptr = NULL;
- t = (int)strtol(cpio->argument, &tptr, 10);
- if (errno || t <= 0 || *(cpio->argument) == '\0' ||
+ t = strtol(cpio->argument, &tptr, 10);
+ if (errno || t <= 0 || t > INT_MAX || *(cpio->argument) == '\0' ||
tptr == NULL || *tptr != '\0') {
lafe_errc(1, 0, "Invalid blocksize: %s",
cpio->argument);
}
- cpio->bytes_per_block = t;
+ cpio->bytes_per_block = (int)t;
break;
case 'c': /* POSIX 1997 */
cpio->format = "odc";
@@ -222,7 +224,7 @@ main(int argc, char *argv[])
if (archive_match_include_pattern_from_file(
cpio->matching, cpio->argument,
cpio->option_null) != ARCHIVE_OK)
- lafe_errc(1, 0, "Error : %s",
+ lafe_errc(1, 0, "%s",
archive_error_string(cpio->matching));
break;
case 'F': /* NetBSD/OpenBSD/GNU cpio */
@@ -231,7 +233,7 @@ main(int argc, char *argv[])
case 'f': /* POSIX 1997 */
if (archive_match_exclude_pattern(cpio->matching,
cpio->argument) != ARCHIVE_OK)
- lafe_errc(1, 0, "Error : %s",
+ lafe_errc(1, 0, "%s",
archive_error_string(cpio->matching));
break;
case OPTION_GRZIP:
@@ -247,7 +249,7 @@ main(int argc, char *argv[])
cpio->filename = cpio->argument;
break;
case 'i': /* POSIX 1997 */
- if (cpio->mode != '\0')
+ if (cpio->mode != '\0' && cpio->mode != opt)
lafe_errc(1, 0,
"Cannot use both -i and -%c", cpio->mode);
cpio->mode = opt;
@@ -289,13 +291,13 @@ main(int argc, char *argv[])
cpio->filename = cpio->argument;
break;
case 'o': /* POSIX 1997 */
- if (cpio->mode != '\0')
+ if (cpio->mode != '\0' && cpio->mode != opt)
lafe_errc(1, 0,
"Cannot use both -o and -%c", cpio->mode);
cpio->mode = opt;
break;
case 'p': /* POSIX 1997 */
- if (cpio->mode != '\0')
+ if (cpio->mode != '\0' && cpio->mode != opt)
lafe_errc(1, 0,
"Cannot use both -p and -%c", cpio->mode);
cpio->mode = opt;
@@ -316,17 +318,21 @@ main(int argc, char *argv[])
if (owner_parse(cpio->argument, &owner, &errmsg) != 0) {
if (!errmsg)
errmsg = "Error parsing owner";
- lafe_warnc(-1, "%s", errmsg);
+ lafe_warnc(0, "%s", errmsg);
usage();
}
if (owner.uid != -1)
cpio->uid_override = owner.uid;
- if (owner.uname != NULL)
+ if (owner.uname != NULL) {
+ free(cpio->uname_override);
cpio->uname_override = owner.uname;
+ }
if (owner.gid != -1)
cpio->gid_override = owner.gid;
- if (owner.gname != NULL)
+ if (owner.gname != NULL) {
+ free(cpio->gname_override);
cpio->gname_override = owner.gname;
+ }
break;
case 'r': /* POSIX 1997 */
cpio->option_rename = 1;
@@ -409,7 +415,7 @@ main(int argc, char *argv[])
while (*cpio->argv != NULL) {
if (archive_match_include_pattern(cpio->matching,
*cpio->argv) != ARCHIVE_OK)
- lafe_errc(1, 0, "Error : %s",
+ lafe_errc(1, 0, "%s",
archive_error_string(cpio->matching));
--cpio->argc;
++cpio->argv;
@@ -427,7 +433,7 @@ main(int argc, char *argv[])
break;
default:
lafe_errc(1, 0,
- "Must specify at least one of -i, -o, or -p");
+ "Must specify one of -i, -o, or -p");
}
archive_match_free(cpio->matching);
@@ -524,7 +530,7 @@ mode_out(struct cpio *cpio)
int r;
if (cpio->option_append)
- lafe_errc(1, 0, "Append mode not yet supported.");
+ lafe_errc(1, 0, "Append mode not yet supported");
cpio->archive_read_disk = archive_read_disk_new();
if (cpio->archive_read_disk == NULL)
@@ -638,7 +644,7 @@ mode_out(struct cpio *cpio)
int64_t blocks =
(archive_filter_bytes(cpio->archive, 0) + 511)
/ 512;
- fprintf(stderr, "%lu %s\n", (unsigned long)blocks,
+ fprintf(stderr, "%lld %s\n", (long long)blocks,
blocks == 1 ? "block" : "blocks");
}
archive_write_free(cpio->archive);
@@ -696,7 +702,6 @@ remove_leading_slash(const char *p)
static int
file_to_archive(struct cpio *cpio, const char *srcpath)
{
- const char *destpath;
struct archive_entry *entry, *spare;
size_t len;
int r;
@@ -738,7 +743,6 @@ file_to_archive(struct cpio *cpio, const char *srcpath)
* pass mode or the name that will go into the archive in
* output mode.
*/
- destpath = srcpath;
if (cpio->destdir) {
len = cpio->destdir_len + strlen(srcpath) + 8;
if (len >= cpio->pass_destpath_alloc) {
@@ -754,15 +758,17 @@ file_to_archive(struct cpio *cpio, const char *srcpath)
}
strcpy(cpio->pass_destpath, cpio->destdir);
strcat(cpio->pass_destpath, remove_leading_slash(srcpath));
- destpath = cpio->pass_destpath;
+ archive_entry_set_pathname(entry, cpio->pass_destpath);
+ } else {
+ archive_entry_set_pathname(entry, srcpath);
}
if (cpio->option_rename)
- destpath = cpio_rename(destpath);
- if (destpath == NULL) {
+ cpio_rename(entry);
+
+ if (archive_entry_pathname(entry) == NULL) {
archive_entry_free(entry);
return (0);
}
- archive_entry_copy_pathname(entry, destpath);
/*
* If we're trying to preserve hardlinks, match them here.
@@ -791,7 +797,6 @@ entry_to_archive(struct cpio *cpio, struct archive_entry *entry)
const char *destpath = archive_entry_pathname(entry);
const char *srcpath = archive_entry_sourcepath(entry);
int fd = -1;
- ssize_t bytes_read;
int r;
/* Print out the destination name to the user. */
@@ -869,21 +874,23 @@ entry_to_archive(struct cpio *cpio, struct archive_entry *entry)
exit(1);
if (r >= ARCHIVE_WARN && archive_entry_size(entry) > 0 && fd >= 0) {
- bytes_read = read(fd, cpio->buff, (unsigned)cpio->buff_size);
+ static char buff[16384];
+ ssize_t bytes_read;
+
+ bytes_read = read(fd, buff, sizeof(buff));
while (bytes_read > 0) {
ssize_t bytes_write;
bytes_write = archive_write_data(cpio->archive,
- cpio->buff, bytes_read);
+ buff, bytes_read);
if (bytes_write < 0)
lafe_errc(1, archive_errno(cpio->archive),
"%s", archive_error_string(cpio->archive));
if (bytes_write < bytes_read) {
lafe_warnc(0,
"Truncated write; file may have "
- "grown while being archived.");
+ "grown while being archived");
}
- bytes_read = read(fd, cpio->buff,
- (unsigned)cpio->buff_size);
+ bytes_read = read(fd, buff, sizeof(buff));
}
}
@@ -997,11 +1004,9 @@ mode_in(struct cpio *cpio)
}
if (archive_match_path_excluded(cpio->matching, entry))
continue;
- if (cpio->option_rename) {
- destpath = cpio_rename(archive_entry_pathname(entry));
- archive_entry_set_pathname(entry, destpath);
- } else
- destpath = archive_entry_pathname(entry);
+ if (cpio->option_rename)
+ cpio_rename(entry);
+ destpath = archive_entry_pathname(entry);
if (destpath == NULL)
continue;
if (cpio->verbose)
@@ -1040,7 +1045,7 @@ mode_in(struct cpio *cpio)
if (!cpio->quiet) {
int64_t blocks = (archive_filter_bytes(a, 0) + 511)
/ 512;
- fprintf(stderr, "%lu %s\n", (unsigned long)blocks,
+ fprintf(stderr, "%lld %s\n", (long long)blocks,
blocks == 1 ? "block" : "blocks");
}
archive_read_free(a);
@@ -1125,7 +1130,7 @@ mode_list(struct cpio *cpio)
if (!cpio->quiet) {
int64_t blocks = (archive_filter_bytes(a, 0) + 511)
/ 512;
- fprintf(stderr, "%lu %s\n", (unsigned long)blocks,
+ fprintf(stderr, "%lld %s\n", (long long)blocks,
blocks == 1 ? "block" : "blocks");
}
archive_read_free(a);
@@ -1292,54 +1297,60 @@ mode_pass(struct cpio *cpio, const char *destdir)
* that an input of '.' means the name should be unchanged. GNU cpio
* treats '.' as a literal new name.
*/
-static const char *
-cpio_rename(const char *name)
+void
+cpio_rename(struct archive_entry *entry)
{
- static char buff[1024];
+ char *buff = NULL, *p, *ret = NULL;
FILE *t;
- char *p, *ret;
+ size_t n = 0;
+ ssize_t r;
#if defined(_WIN32) && !defined(__CYGWIN__)
FILE *to;
t = fopen("CONIN$", "r");
if (t == NULL)
- return (name);
+ return;
to = fopen("CONOUT$", "w");
if (to == NULL) {
fclose(t);
- return (name);
+ return;
}
- fprintf(to, "%s (Enter/./(new name))? ", name);
+ fprintf(to, "%s (Enter/./(new name))? ", archive_entry_pathname(entry));
fclose(to);
#else
t = fopen("/dev/tty", "r+");
if (t == NULL)
- return (name);
- fprintf(t, "%s (Enter/./(new name))? ", name);
+ return;
+ fprintf(t, "%s (Enter/./(new name))? ", archive_entry_pathname(entry));
fflush(t);
#endif
- p = fgets(buff, sizeof(buff), t);
+ r = getline(&buff, &n, t);
fclose(t);
- if (p == NULL)
+ if (r < 1)
/* End-of-file is a blank line. */
- return (NULL);
+ goto done;
+ p = buff;
while (*p == ' ' || *p == '\t')
++p;
if (*p == '\n' || *p == '\0')
/* Empty line. */
- return (NULL);
- if (*p == '.' && p[1] == '\n')
+ goto done;
+ if (*p == '.' && p[1] == '\n') {
/* Single period preserves original name. */
- return (name);
+ free(buff);
+ return;
+ }
ret = p;
/* Trim the final newline. */
while (*p != '\0' && *p != '\n')
++p;
/* Overwrite the final \n with a null character. */
*p = '\0';
- return (ret);
+done:
+ archive_entry_set_pathname(entry, ret);
+ free(buff);
}
static void
diff --git a/contrib/libarchive/cpio/cpio.h b/contrib/libarchive/cpio/cpio.h
index 9bc631b544fe..2621a4c3dda3 100644
--- a/contrib/libarchive/cpio/cpio.h
+++ b/contrib/libarchive/cpio/cpio.h
@@ -71,8 +71,6 @@ struct cpio {
/* Work data. */
struct archive *matching;
- char *buff;
- size_t buff_size;
char *ppbuff;
};
diff --git a/contrib/libarchive/cpio/test/test_format_newc.c b/contrib/libarchive/cpio/test/test_format_newc.c
index 33aa16d07a81..9d4e4e9fb674 100644
--- a/contrib/libarchive/cpio/test/test_format_newc.c
+++ b/contrib/libarchive/cpio/test/test_format_newc.c
@@ -6,6 +6,13 @@
*/
#include "test.h"
+#ifdef HAVE_GETEUID
+#define getuid() geteuid()
+#endif
+#ifdef HAVE_GETEGID
+#define getgid() getegid()
+#endif
+
/* Number of bytes needed to pad 'n' to multiple of 'block', assuming
* that 'block' is a power of two. This trick can be more easily
* remembered as -n & (block - 1), but many compilers quite reasonably
diff --git a/contrib/libarchive/libarchive/archive.h b/contrib/libarchive/libarchive/archive.h
index a9d34beb4f5a..41a5440cac75 100644
--- a/contrib/libarchive/libarchive/archive.h
+++ b/contrib/libarchive/libarchive/archive.h
@@ -34,7 +34,7 @@
* assert that ARCHIVE_VERSION_NUMBER >= 2012108.
*/
/* Note: Compiler will complain if this does not match archive_entry.h! */
-#define ARCHIVE_VERSION_NUMBER 3008005
+#define ARCHIVE_VERSION_NUMBER 3008007
#include <sys/stat.h>
#include <stddef.h> /* for wchar_t */
@@ -177,7 +177,7 @@ __LA_DECL int archive_version_number(void);
/*
* Textual name/version of the library, useful for version displays.
*/
-#define ARCHIVE_VERSION_ONLY_STRING "3.8.5"
+#define ARCHIVE_VERSION_ONLY_STRING "3.8.7"
#define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
__LA_DECL const char * archive_version_string(void);
diff --git a/contrib/libarchive/libarchive/archive_acl.c b/contrib/libarchive/libarchive/archive_acl.c
index 362e3308f43f..ab601833def6 100644
--- a/contrib/libarchive/libarchive/archive_acl.c
+++ b/contrib/libarchive/libarchive/archive_acl.c
@@ -1256,8 +1256,12 @@ archive_acl_from_text_w(struct archive_acl *acl, const wchar_t *text,
tag = 0;
s = field[n].start;
- st = field[n].start + 1;
len = field[n].end - field[n].start;
+ if (len == 0) {
+ ret = ARCHIVE_WARN;
+ continue;
+ }
+ st = s + 1;
switch (*s) {
case L'u':
diff --git a/contrib/libarchive/libarchive/archive_check_magic.c b/contrib/libarchive/libarchive/archive_check_magic.c
index 6b8e0c5595f4..b6e1257949e1 100644
--- a/contrib/libarchive/libarchive/archive_check_magic.c
+++ b/contrib/libarchive/libarchive/archive_check_magic.c
@@ -148,14 +148,14 @@ __archive_check_magic(struct archive *a, unsigned int magic,
if (!handle_type) {
errmsg("PROGRAMMER ERROR: Function ");
errmsg(function);
- errmsg(" invoked with invalid archive handle.\n");
+ errmsg(" invoked with invalid archive handle\n");
diediedie();
}
if (a->magic != magic) {
archive_set_error(a, -1,
"PROGRAMMER ERROR: Function '%s' invoked"
- " on '%s' archive object, which is not supported.",
+ " on '%s' archive object, which is not supported",
function,
handle_type);
a->state = ARCHIVE_STATE_FATAL;
diff --git a/contrib/libarchive/libarchive/archive_cryptor_private.h b/contrib/libarchive/libarchive/archive_cryptor_private.h
index 272f2f84b9c9..1f9298ffdc46 100644
--- a/contrib/libarchive/libarchive/archive_cryptor_private.h
+++ b/contrib/libarchive/libarchive/archive_cryptor_private.h
@@ -109,6 +109,10 @@ typedef struct {
#include <nettle/version.h>
#define ARCHIVE_CRYPTOR_USE_NETTLE 1
+#ifndef AES_MAX_KEY_SIZE
+#define AES_MAX_KEY_SIZE AES256_KEY_SIZE
+#endif
+
typedef struct {
#if NETTLE_VERSION_MAJOR < 3
struct aes_ctx ctx;
diff --git a/contrib/libarchive/libarchive/archive_entry.h b/contrib/libarchive/libarchive/archive_entry.h
index b43435692c27..7122a74ed007 100644
--- a/contrib/libarchive/libarchive/archive_entry.h
+++ b/contrib/libarchive/libarchive/archive_entry.h
@@ -28,7 +28,7 @@
#define ARCHIVE_ENTRY_H_INCLUDED
/* Note: Compiler will complain if this does not match archive.h! */
-#define ARCHIVE_VERSION_NUMBER 3008005
+#define ARCHIVE_VERSION_NUMBER 3008007
/*
* Note: archive_entry.h is for use outside of libarchive; the
diff --git a/contrib/libarchive/libarchive/archive_hmac.c b/contrib/libarchive/libarchive/archive_hmac.c
index 210cca70744d..458092f41b29 100644
--- a/contrib/libarchive/libarchive/archive_hmac.c
+++ b/contrib/libarchive/libarchive/archive_hmac.c
@@ -198,6 +198,7 @@ static void __hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx)
}
#elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_HMAC_H)
+#include <nettle/version.h>
static int
__hmac_sha1_init(archive_hmac_sha1_ctx *ctx, const uint8_t *key, size_t key_len)
@@ -216,7 +217,12 @@ __hmac_sha1_update(archive_hmac_sha1_ctx *ctx, const uint8_t *data,
static void
__hmac_sha1_final(archive_hmac_sha1_ctx *ctx, uint8_t *out, size_t *out_len)
{
+#if NETTLE_VERSION_MAJOR < 4
hmac_sha1_digest(ctx, (unsigned)*out_len, out);
+#else
+ hmac_sha1_digest(ctx, out);
+ *out_len = SHA1_DIGEST_SIZE;
+#endif
}
static void
diff --git a/contrib/libarchive/libarchive/archive_options.c b/contrib/libarchive/libarchive/archive_options.c
index 6e2c0d2a5971..66491bd4183b 100644
--- a/contrib/libarchive/libarchive/archive_options.c
+++ b/contrib/libarchive/libarchive/archive_options.c
@@ -90,7 +90,9 @@ _archive_set_either_option(struct archive *a, const char *m, const char *o, cons
if (r2 == ARCHIVE_FATAL)
return (ARCHIVE_FATAL);
- if (r2 == ARCHIVE_WARN - 1)
+ if (r1 == ARCHIVE_WARN - 1)
+ return r2;
+ if (r2 == ARCHIVE_WARN -1)
return r1;
return r1 > r2 ? r1 : r2;
}
diff --git a/contrib/libarchive/libarchive/archive_pathmatch.c b/contrib/libarchive/libarchive/archive_pathmatch.c
index 19e0889ffe55..db0d2b791adf 100644
--- a/contrib/libarchive/libarchive/archive_pathmatch.c
+++ b/contrib/libarchive/libarchive/archive_pathmatch.c
@@ -202,7 +202,7 @@ pm(const char *p, const char *s, int flags)
if (*p == '\0')
return (1);
while (*s) {
- if (archive_pathmatch(p, s, flags))
+ if (pm(p, s, flags))
return (1);
++s;
}
@@ -307,7 +307,7 @@ pm_w(const wchar_t *p, const wchar_t *s, int flags)
if (*p == L'\0')
return (1);
while (*s) {
- if (archive_pathmatch_w(p, s, flags))
+ if (pm_w(p, s, flags))
return (1);
++s;
}
diff --git a/contrib/libarchive/libarchive/archive_ppmd8.c b/contrib/libarchive/libarchive/archive_ppmd8.c
index 30196d64a9f5..04b1c0c3e165 100644
--- a/contrib/libarchive/libarchive/archive_ppmd8.c
+++ b/contrib/libarchive/libarchive/archive_ppmd8.c
@@ -61,7 +61,7 @@ typedef struct CPpmd8_Node_
#define EMPTY_NODE 0xFFFFFFFF
-void Ppmd8_Construct(CPpmd8 *p)
+static void Ppmd8_Construct(CPpmd8 *p)
{
unsigned i, k, m;
@@ -89,14 +89,14 @@ void Ppmd8_Construct(CPpmd8 *p)
}
}
-void Ppmd8_Free(CPpmd8 *p)
+static void Ppmd8_Free(CPpmd8 *p)
{
free(p->Base);
p->Size = 0;
p->Base = 0;
}
-Bool Ppmd8_Alloc(CPpmd8 *p, UInt32 size)
+static Bool Ppmd8_Alloc(CPpmd8 *p, UInt32 size)
{
if (p->Base == 0 || p->Size != size)
{
@@ -407,7 +407,7 @@ static void RestartModel(CPpmd8 *p)
}
}
-void Ppmd8_Init(CPpmd8 *p, unsigned maxOrder, unsigned restoreMethod)
+static void Ppmd8_Init(CPpmd8 *p, unsigned maxOrder, unsigned restoreMethod)
{
p->MaxOrder = maxOrder;
p->RestoreMethod = restoreMethod;
@@ -1042,7 +1042,7 @@ static void Rescale(CPpmd8 *p)
p->FoundState = STATS(p->MinContext);
}
-CPpmd_See *Ppmd8_MakeEscFreq(CPpmd8 *p, unsigned numMasked1, UInt32 *escFreq)
+static CPpmd_See *Ppmd8_MakeEscFreq(CPpmd8 *p, unsigned numMasked1, UInt32 *escFreq)
{
CPpmd_See *see;
if (p->MinContext->NumStats != 0xFF)
@@ -1078,7 +1078,7 @@ static void NextContext(CPpmd8 *p)
}
}
-void Ppmd8_Update1(CPpmd8 *p)
+static void Ppmd8_Update1(CPpmd8 *p)
{
CPpmd_State *s = p->FoundState;
s->Freq += 4;
@@ -1093,7 +1093,7 @@ void Ppmd8_Update1(CPpmd8 *p)
NextContext(p);
}
-void Ppmd8_Update1_0(CPpmd8 *p)
+static void Ppmd8_Update1_0(CPpmd8 *p)
{
p->PrevSuccess = (2 * p->FoundState->Freq >= p->MinContext->SummFreq);
p->RunLength += p->PrevSuccess;
@@ -1103,7 +1103,7 @@ void Ppmd8_Update1_0(CPpmd8 *p)
NextContext(p);
}
-void Ppmd8_UpdateBin(CPpmd8 *p)
+static void Ppmd8_UpdateBin(CPpmd8 *p)
{
p->FoundState->Freq = (Byte)(p->FoundState->Freq + (p->FoundState->Freq < 196));
p->PrevSuccess = 1;
@@ -1111,7 +1111,7 @@ void Ppmd8_UpdateBin(CPpmd8 *p)
NextContext(p);
}
-void Ppmd8_Update2(CPpmd8 *p)
+static void Ppmd8_Update2(CPpmd8 *p)
{
p->MinContext->SummFreq += 4;
if ((p->FoundState->Freq += 4) > MAX_FREQ)
@@ -1127,7 +1127,7 @@ This code is based on:
PPMd var.I (2002): Dmitry Shkarin : Public domain
Carryless rangecoder (1999): Dmitry Subbotin : Public domain */
-Bool Ppmd8_RangeDec_Init(CPpmd8 *p)
+static Bool Ppmd8_RangeDec_Init(CPpmd8 *p)
{
unsigned i;
p->Low = 0;
@@ -1161,7 +1161,7 @@ static void RangeDec_Decode(CPpmd8 *p, UInt32 start, UInt32 size)
#define MASK(sym) ((signed char *)charMask)[sym]
-int Ppmd8_DecodeSymbol(CPpmd8 *p)
+static int Ppmd8_DecodeSymbol(CPpmd8 *p)
{
size_t charMask[256 / sizeof(size_t)];
if (p->MinContext->NumStats != 0)
diff --git a/contrib/libarchive/libarchive/archive_ppmd8_private.h b/contrib/libarchive/libarchive/archive_ppmd8_private.h
index 454b75f41f25..f0493de04623 100644
--- a/contrib/libarchive/libarchive/archive_ppmd8_private.h
+++ b/contrib/libarchive/libarchive/archive_ppmd8_private.h
@@ -83,12 +83,6 @@ typedef struct
UInt16 BinSumm[25][64];
} CPpmd8;
-void Ppmd8_Construct(CPpmd8 *p);
-Bool Ppmd8_Alloc(CPpmd8 *p, UInt32 size);
-void Ppmd8_Free(CPpmd8 *p);
-void Ppmd8_Init(CPpmd8 *p, unsigned maxOrder, unsigned restoreMethod);
-#define Ppmd8_WasAllocated(p) ((p)->Base != NULL)
-
/* ---------- Internal Functions ---------- */
@@ -104,30 +98,11 @@ extern const Byte PPMD8_kExpEscape[16];
#define Ppmd8_GetStats(p, ctx) ((CPpmd_State *)Ppmd8_GetPtr((p), ((ctx)->Stats)))
#endif
-void Ppmd8_Update1(CPpmd8 *p);
-void Ppmd8_Update1_0(CPpmd8 *p);
-void Ppmd8_Update2(CPpmd8 *p);
-void Ppmd8_UpdateBin(CPpmd8 *p);
-
#define Ppmd8_GetBinSumm(p) \
&p->BinSumm[p->NS2Indx[Ppmd8Context_OneState(p->MinContext)->Freq - 1]][ \
p->NS2BSIndx[Ppmd8_GetContext(p, p->MinContext->Suffix)->NumStats] + \
p->PrevSuccess + p->MinContext->Flags + ((p->RunLength >> 26) & 0x20)]
-CPpmd_See *Ppmd8_MakeEscFreq(CPpmd8 *p, unsigned numMasked, UInt32 *scale);
-
-
-/* ---------- Decode ---------- */
-
-Bool Ppmd8_RangeDec_Init(CPpmd8 *p);
-#define Ppmd8_RangeDec_IsFinishedOK(p) ((p)->Code == 0)
-int Ppmd8_DecodeSymbol(CPpmd8 *p); /* returns: -1 as EndMarker, -2 as DataError */
-
-/* ---------- Encode ---------- */
-
-#define Ppmd8_RangeEnc_Init(p) { (p)->Low = 0; (p)->Range = 0xFFFFFFFF; }
-void Ppmd8_RangeEnc_FlushData(CPpmd8 *p);
-void Ppmd8_EncodeSymbol(CPpmd8 *p, int symbol); /* symbol = -1 means EndMarker */
typedef struct
{
diff --git a/contrib/libarchive/libarchive/archive_read.c b/contrib/libarchive/libarchive/archive_read.c
index c9b9d5981516..e5f89bdc8772 100644
--- a/contrib/libarchive/libarchive/archive_read.c
+++ b/contrib/libarchive/libarchive/archive_read.c
@@ -171,7 +171,7 @@ static int64_t
client_skip_proxy(struct archive_read_filter *self, int64_t request)
{
if (request < 0)
- __archive_errx(1, "Negative skip requested.");
+ __archive_errx(1, "Negative skip requested");
if (request == 0)
return 0;
@@ -379,7 +379,7 @@ archive_read_set_callback_data2(struct archive *_a, void *client_data,
if (a->client.dataset == NULL)
{
archive_set_error(&a->archive, ENOMEM,
- "No memory.");
+ "No memory");
return ARCHIVE_FATAL;
}
a->client.nodes = 1;
@@ -388,7 +388,7 @@ archive_read_set_callback_data2(struct archive *_a, void *client_data,
if (iindex > a->client.nodes - 1)
{
archive_set_error(&a->archive, EINVAL,
- "Invalid index specified.");
+ "Invalid index specified");
return ARCHIVE_FATAL;
}
a->client.dataset[iindex].data = client_data;
@@ -409,14 +409,14 @@ archive_read_add_callback_data(struct archive *_a, void *client_data,
"archive_read_add_callback_data");
if (iindex > a->client.nodes) {
archive_set_error(&a->archive, EINVAL,
- "Invalid index specified.");
+ "Invalid index specified");
return ARCHIVE_FATAL;
}
p = realloc(a->client.dataset, sizeof(*a->client.dataset)
* (++(a->client.nodes)));
if (p == NULL) {
archive_set_error(&a->archive, ENOMEM,
- "No memory.");
+ "No memory");
return ARCHIVE_FATAL;
}
a->client.dataset = (struct archive_read_data_node *)p;
@@ -625,7 +625,7 @@ _archive_read_next_header2(struct archive *_a, struct archive_entry *entry)
r1 = archive_read_data_skip(&a->archive);
if (r1 == ARCHIVE_EOF)
archive_set_error(&a->archive, EIO,
- "Premature end-of-file.");
+ "Premature end-of-file");
if (r1 == ARCHIVE_EOF || r1 == ARCHIVE_FATAL) {
a->archive.state = ARCHIVE_STATE_FATAL;
return (ARCHIVE_FATAL);
diff --git a/contrib/libarchive/libarchive/archive_read_append_filter.c b/contrib/libarchive/libarchive/archive_read_append_filter.c
index cd88df119906..d578b06fe714 100644
--- a/contrib/libarchive/libarchive/archive_read_append_filter.c
+++ b/contrib/libarchive/libarchive/archive_read_append_filter.c
@@ -104,6 +104,10 @@ archive_read_append_filter(struct archive *_a, int code)
strcpy(str, "lrzip");
r1 = archive_read_support_filter_lrzip(_a);
break;
+ case ARCHIVE_FILTER_GRZIP:
*** 5263 LINES SKIPPED ***