Update to 3.2.0. Notable changes include:

* Incorporate patches for crash and overflow bugs
* Add support for lz4 compression
* Add bsdcat command-line tool

Also avoid picking up ext2fs header; reported by rpe@
This commit is contained in:
naddy 2016-05-26 20:31:37 +00:00
parent 075bc2ad30
commit 228abeda46
13 changed files with 24 additions and 307 deletions

View File

@ -1,9 +1,8 @@
# $OpenBSD: Makefile,v 1.29 2016/04/06 14:16:58 naddy Exp $
# $OpenBSD: Makefile,v 1.30 2016/05/26 20:31:37 naddy Exp $
COMMENT= multi-format archive and compression library
DISTNAME= libarchive-3.1.2
REVISION= 0
DISTNAME= libarchive-3.2.0
SHARED_LIBS= archive 8.2 # 14.2
CATEGORIES= archivers
HOMEPAGE= http://www.libarchive.org/
@ -15,8 +14,9 @@ PERMIT_PACKAGE_CDROM= Yes
MASTER_SITES= http://www.libarchive.org/downloads/
WANTLIB= bz2 c expat iconv lzma lzo2 pthread z
WANTLIB= bz2 c expat iconv lz4 lzma lzo2 pthread z
LIB_DEPENDS= archivers/bzip2 \
archivers/lz4 \
archivers/lzo2 \
archivers/xz \
converters/libiconv
@ -28,20 +28,11 @@ CONFIGURE_ARGS+=--without-nettle # prefer OpenSSL
CONFIGURE_ARGS+=--without-xml2 # expat suffices
CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include" \
LDFLAGS="-L${LOCALBASE}/lib"
# Do not pick up headers from e2fsprogs
CONFIGURE_ENV+= ac_cv_header_ext2fs_ext2_fs_h=no
MODGNU_CONFIG_GUESS_DIRS=${WRKSRC}/build/autoconf
# Regression tests known to fail due to locale issues
# (see /tmp/libarchive_test.* for detailed logs):
#
# test_gnutar_filename_encoding
# test_pax_filename_encoding
# test_read_format_cpio_filename
# test_read_format_gtar_filename
# test_read_format_rar_unicode_CP932
# test_read_format_tar_filename
# test_read_format_ustar_filename
# test_read_format_zip_filename
# test_ustar_filename_encoding
# test_zip_filename_encoding
# Note: Numerous regression tests fail due to locale issues
.include <bsd.port.mk>

View File

@ -1,2 +1,2 @@
SHA256 (libarchive-3.1.2.tar.gz) = 64fqzY/kno2QyP3BiYEwI8zDGcXnUrAftq0Mx7LFPV4=
SIZE (libarchive-3.1.2.tar.gz) = 4527540
SHA256 (libarchive-3.2.0.tar.gz) = e85F/XH/Adwg0Z7deDItSWVYPYG4vtjibKy2XW9bqoc=
SIZE (libarchive-3.2.0.tar.gz) = 5448095

View File

@ -1,14 +1,6 @@
$OpenBSD: patch-cpio_bsdcpio_1,v 1.3 2016/01/30 23:34:44 naddy Exp $
Match installed name.
CVE-2015-2304
Commit 5935715
Add ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS option
This fixes a directory traversal in the cpio tool.
--- cpio/bsdcpio.1.orig Mon Jan 14 02:43:45 2013
+++ cpio/bsdcpio.1 Sat Jan 30 21:33:16 2016
$OpenBSD: patch-cpio_bsdcpio_1,v 1.4 2016/05/26 20:31:37 naddy Exp $
--- cpio/bsdcpio.1.orig Tue Jan 10 07:41:09 2012
+++ cpio/bsdcpio.1 Sat Mar 31 21:50:15 2012
@@ -28,7 +28,7 @@
.Dt CPIO 1
.Os
@ -18,13 +10,3 @@ Commit 5935715
.Nd copy files to and from archives
.Sh SYNOPSIS
.Nm
@@ -156,7 +156,8 @@ See above for description.
.It Fl Fl insecure
(i and p mode only)
Disable security checks during extraction or copying.
-This allows extraction via symbolic links and path names containing
+This allows extraction via symbolic links, absolute paths,
+and path names containing
.Sq ..
in the name.
.It Fl J , Fl Fl xz

View File

@ -1,25 +0,0 @@
$OpenBSD: patch-cpio_cpio_c,v 1.1 2016/01/30 23:34:44 naddy Exp $
CVE-2015-2304
Commit 5935715
Add ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS option
This fixes a directory traversal in the cpio tool.
--- cpio/cpio.c.orig Mon Jan 14 02:43:45 2013
+++ cpio/cpio.c Sat Jan 30 21:33:16 2016
@@ -179,6 +179,7 @@ main(int argc, char *argv[])
cpio->extract_flags |= ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER;
cpio->extract_flags |= ARCHIVE_EXTRACT_SECURE_SYMLINKS;
cpio->extract_flags |= ARCHIVE_EXTRACT_SECURE_NODOTDOT;
+ cpio->extract_flags |= ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS;
cpio->extract_flags |= ARCHIVE_EXTRACT_PERM;
cpio->extract_flags |= ARCHIVE_EXTRACT_FFLAGS;
cpio->extract_flags |= ARCHIVE_EXTRACT_ACL;
@@ -264,6 +265,7 @@ main(int argc, char *argv[])
case OPTION_INSECURE:
cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_SYMLINKS;
cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NODOTDOT;
+ cpio->extract_flags &= ~ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS;
break;
case 'L': /* GNU cpio */
cpio->option_follow_links = 1;

View File

@ -1,18 +0,0 @@
$OpenBSD: patch-libarchive_archive_h,v 1.1 2016/01/30 23:34:44 naddy Exp $
CVE-2015-2304
Commit 5935715
Add ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS option
This fixes a directory traversal in the cpio tool.
--- libarchive/archive.h.orig Sat Feb 9 18:23:03 2013
+++ libarchive/archive.h Sat Jan 30 21:33:16 2016
@@ -562,6 +562,8 @@ __LA_DECL int archive_read_set_options(struct archive
/* Default: Do not use HFS+ compression if it was not compressed. */
/* This has no effect except on Mac OS v10.6 or later. */
#define ARCHIVE_EXTRACT_HFS_COMPRESSION_FORCED (0x8000)
+/* Default: Do not reject entries with absolute paths */
+#define ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS (0x10000)
__LA_DECL int archive_read_extract(struct archive *, struct archive_entry *,
int flags);

View File

@ -1,17 +0,0 @@
$OpenBSD: patch-libarchive_archive_read_c,v 1.1 2016/01/30 23:34:44 naddy Exp $
Commit e6c9668
Add a check to archive_read_filter_consume to reject any
attempts to move the file pointer by a negative amount.
--- libarchive/archive_read.c.orig Fri Feb 8 04:24:42 2013
+++ libarchive/archive_read.c Sat Jan 30 21:40:21 2016
@@ -1394,6 +1394,8 @@ __archive_read_filter_consume(struct archive_read_filt
{
int64_t skipped;
+ if (request < 0)
+ return ARCHIVE_FATAL;
if (request == 0)
return 0;

View File

@ -1,80 +0,0 @@
$OpenBSD: patch-libarchive_archive_read_support_format_cpio_c,v 1.1 2016/01/30 23:34:44 naddy Exp $
Commit 3865cf2
Issue 394: Segfault when reading malformed old-style cpio archives
Root cause here was an implicit cast that resulted in
reading very large file sizes as negative numbers.
Hunk 2, 3:
Commit 24f5de6
Set a proper error message if we hit end-of-file when
trying to read a cpio header.
--- libarchive/archive_read_support_format_cpio.c.orig Mon Jan 14 02:43:45 2013
+++ libarchive/archive_read_support_format_cpio.c Sat Jan 30 21:41:37 2016
@@ -198,7 +198,7 @@ static int archive_read_format_cpio_read_data(struct a
static int archive_read_format_cpio_read_header(struct archive_read *,
struct archive_entry *);
static int archive_read_format_cpio_skip(struct archive_read *);
-static int be4(const unsigned char *);
+static int64_t be4(const unsigned char *);
static int find_odc_header(struct archive_read *);
static int find_newc_header(struct archive_read *);
static int header_bin_be(struct archive_read *, struct cpio *,
@@ -213,7 +213,7 @@ static int header_afiol(struct archive_read *, struct
struct archive_entry *, size_t *, size_t *);
static int is_octal(const char *, size_t);
static int is_hex(const char *, size_t);
-static int le4(const unsigned char *);
+static int64_t le4(const unsigned char *);
static int record_hardlink(struct archive_read *a,
struct cpio *cpio, struct archive_entry *entry);
@@ -864,8 +864,11 @@ header_bin_le(struct archive_read *a, struct cpio *cpi
/* Read fixed-size portion of header. */
h = __archive_read_ahead(a, bin_header_size, NULL);
- if (h == NULL)
+ if (h == NULL) {
+ archive_set_error(&a->archive, 0,
+ "End of file trying to read next cpio header");
return (ARCHIVE_FATAL);
+ }
/* Parse out binary fields. */
header = (const unsigned char *)h;
@@ -900,8 +903,11 @@ header_bin_be(struct archive_read *a, struct cpio *cpi
/* Read fixed-size portion of header. */
h = __archive_read_ahead(a, bin_header_size, NULL);
- if (h == NULL)
+ if (h == NULL) {
+ archive_set_error(&a->archive, 0,
+ "End of file trying to read next cpio header");
return (ARCHIVE_FATAL);
+ }
/* Parse out binary fields. */
header = (const unsigned char *)h;
@@ -944,17 +950,17 @@ archive_read_format_cpio_cleanup(struct archive_read *
return (ARCHIVE_OK);
}
-static int
+static int64_t
le4(const unsigned char *p)
{
- return ((p[0]<<16) + (p[1]<<24) + (p[2]<<0) + (p[3]<<8));
+ return ((p[0] << 16) + (((int64_t)p[1]) << 24) + (p[2] << 0) + (p[3] << 8));
}
-static int
+static int64_t
be4(const unsigned char *p)
{
- return ((p[0]<<24) + (p[1]<<16) + (p[2]<<8) + (p[3]));
+ return ((((int64_t)p[0]) << 24) + (p[1] << 16) + (p[2] << 8) + (p[3]));
}
/*

View File

@ -1,24 +0,0 @@
$OpenBSD: patch-libarchive_archive_write_c,v 1.1 2016/01/30 23:34:44 naddy Exp $
CVE-2013-0211
Commits 2253154
Limit write requests to at most INT_MAX.
This prevents a certain common programming error (passing -1 to write)
from leading to other problems deeper in the library.
--- libarchive/archive_write.c.orig Mon Jan 14 02:43:45 2013
+++ libarchive/archive_write.c Sat Jan 30 21:29:06 2016
@@ -671,8 +671,13 @@ static ssize_t
_archive_write_data(struct archive *_a, const void *buff, size_t s)
{
struct archive_write *a = (struct archive_write *)_a;
+ const size_t max_write = INT_MAX;
+
archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
ARCHIVE_STATE_DATA, "archive_write_data");
+ /* In particular, this catches attempts to pass negative values. */
+ if (s > max_write)
+ s = max_write;
archive_clear_error(&a->archive);
return ((a->format_write_data)(a, buff, s));
}

View File

@ -1,19 +0,0 @@
$OpenBSD: patch-libarchive_archive_write_disk_3,v 1.1 2016/01/30 23:34:44 naddy Exp $
CVE-2015-2304
Commit 5935715
Add ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS option
This fixes a directory traversal in the cpio tool.
--- libarchive/archive_write_disk.3.orig Sun Jan 13 22:10:46 2013
+++ libarchive/archive_write_disk.3 Sat Jan 30 21:33:16 2016
@@ -177,6 +177,9 @@ The default is to not refuse such paths.
Note that paths ending in
.Pa ..
always cause an error, regardless of this flag.
+.It Cm ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS
+Refuse to extract an absolute path.
+The default is to not refuse such paths.
.It Cm ARCHIVE_EXTRACT_SPARSE
Scan data for blocks of NUL bytes and try to recreate them with holes.
This results in sparse files, independent of whether the archive format

View File

@ -1,38 +0,0 @@
$OpenBSD: patch-libarchive_archive_write_disk_posix_c,v 1.1 2016/01/30 23:34:44 naddy Exp $
CVE-2015-2304
Commit 5935715
Add ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS option
This fixes a directory traversal in the cpio tool.
--- libarchive/archive_write_disk_posix.c.orig Fri Feb 8 01:52:07 2013
+++ libarchive/archive_write_disk_posix.c Sat Jan 30 21:33:16 2016
@@ -2504,8 +2504,9 @@ cleanup_pathname_win(struct archive_write_disk *a)
/*
* Canonicalize the pathname. In particular, this strips duplicate
* '/' characters, '.' elements, and trailing '/'. It also raises an
- * error for an empty path, a trailing '..' or (if _SECURE_NODOTDOT is
- * set) any '..' in the path.
+ * error for an empty path, a trailing '..', (if _SECURE_NODOTDOT is
+ * set) any '..' in the path or (if ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS
+ * is set) if the path is absolute.
*/
static int
cleanup_pathname(struct archive_write_disk *a)
@@ -2524,8 +2525,15 @@ cleanup_pathname(struct archive_write_disk *a)
cleanup_pathname_win(a);
#endif
/* Skip leading '/'. */
- if (*src == '/')
+ if (*src == '/') {
+ if (a->flags & ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Path is absolute");
+ return (ARCHIVE_FAILED);
+ }
+
separator = *src++;
+ }
/* Scan the pathname one element at a time. */
for (;;) {

View File

@ -1,39 +0,0 @@
$OpenBSD: patch-libarchive_test_test_write_disk_secure_c,v 1.1 2016/01/30 23:34:44 naddy Exp $
CVE-2015-2304
Commit 5935715
Add ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS option
This fixes a directory traversal in the cpio tool.
--- libarchive/test/test_write_disk_secure.c.orig Sun Jan 13 22:10:46 2013
+++ libarchive/test/test_write_disk_secure.c Sat Jan 30 21:33:16 2016
@@ -178,6 +178,29 @@ DEFINE_TEST(test_write_disk_secure)
assert(S_ISDIR(st.st_mode));
archive_entry_free(ae);
+ /*
+ * Without security checks, we should be able to
+ * 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");
+ 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"));
+
+ /* 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_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");
+
assertEqualInt(ARCHIVE_OK, archive_write_free(a));
/* Test the entries on disk. */

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-tar_bsdtar_1,v 1.9 2015/04/04 11:05:19 naddy Exp $
--- tar/bsdtar.1.orig Mon Jan 14 02:43:45 2013
+++ tar/bsdtar.1 Sat Mar 23 00:24:09 2013
$OpenBSD: patch-tar_bsdtar_1,v 1.10 2016/05/26 20:31:37 naddy Exp $
--- tar/bsdtar.1.orig Mon Apr 11 02:50:14 2016
+++ tar/bsdtar.1 Tue May 10 22:10:39 2016
@@ -28,7 +28,7 @@
.Dt TAR 1
.Os
@ -10,16 +10,16 @@ $OpenBSD: patch-tar_bsdtar_1,v 1.9 2015/04/04 11:05:19 naddy Exp $
.Nd manipulate tape archives
.Sh SYNOPSIS
.Nm
@@ -214,11 +214,8 @@ The filename can be
@@ -218,11 +218,9 @@ The filename can be
for standard input or standard output.
The default varies by system;
on
-.Fx ,
-the default is
+.Ox ,
the default is
-.Pa /dev/sa0 ;
-on Linux, the default is
-.Pa /dev/st0 .
+.Ox ,
+.Pa /dev/rst0 .
.It Fl Fl gid Ar id
Use the provided group id number.

View File

@ -1,4 +1,5 @@
@comment $OpenBSD: PLIST,v 1.10 2015/04/04 11:05:19 naddy Exp $
@comment $OpenBSD: PLIST,v 1.11 2016/05/26 20:31:37 naddy Exp $
@bin bin/bsdcat
@bin bin/bsdcpio
@bin bin/bsdtar
include/archive.h
@ -7,6 +8,7 @@ lib/libarchive.a
lib/libarchive.la
@lib lib/libarchive.so.${LIBarchive_VERSION}
lib/pkgconfig/libarchive.pc
@man man/man1/bsdcat.1
@man man/man1/bsdcpio.1
@man man/man1/bsdtar.1
@man man/man3/archive_entry.3
@ -17,6 +19,7 @@ lib/pkgconfig/libarchive.pc
@man man/man3/archive_entry_stat.3
@man man/man3/archive_entry_time.3
@man man/man3/archive_read.3
@man man/man3/archive_read_add_passphrase.3
@man man/man3/archive_read_data.3
@man man/man3/archive_read_disk.3
@man man/man3/archive_read_extract.3
@ -40,6 +43,7 @@ lib/pkgconfig/libarchive.pc
@man man/man3/archive_write_new.3
@man man/man3/archive_write_open.3
@man man/man3/archive_write_set_options.3
@man man/man3/archive_write_set_passphrase.3
@man man/man3/libarchive.3
@man man/man3/libarchive_changes.3
@man man/man3/libarchive_internals.3