Date: Tuesday, November 1, 2022 @ 11:27:45
  Author: foutrelis
Revision: 459782

archrelease: copy trunk to staging-x86_64

Added:
  libarchive/repos/staging-x86_64/
  
libarchive/repos/staging-x86_64/0001-libarchive-Handle-a-calloc-returning-NULL-fixes-1754.patch
    (from rev 459781, 
libarchive/trunk/0001-libarchive-Handle-a-calloc-returning-NULL-fixes-1754.patch)
  
libarchive/repos/staging-x86_64/0002-Validate-entry_bytes_remaining-in-pax_attribute.patch
    (from rev 459781, 
libarchive/trunk/0002-Validate-entry_bytes_remaining-in-pax_attribute.patch)
  
libarchive/repos/staging-x86_64/0003-libarchive-Do-not-include-sys-mount.h-when-linux-fs..patch
    (from rev 459781, 
libarchive/trunk/0003-libarchive-Do-not-include-sys-mount.h-when-linux-fs..patch)
  libarchive/repos/staging-x86_64/PKGBUILD
    (from rev 459781, libarchive/trunk/PKGBUILD)
  libarchive/repos/staging-x86_64/keys/

-----------------------------------------------------------------+
 0001-libarchive-Handle-a-calloc-returning-NULL-fixes-1754.patch |   35 ++++++
 0002-Validate-entry_bytes_remaining-in-pax_attribute.patch      |   42 +++++++
 0003-libarchive-Do-not-include-sys-mount.h-when-linux-fs..patch |   40 +++++++
 PKGBUILD                                                        |   55 
++++++++++
 4 files changed, 172 insertions(+)

Copied: 
libarchive/repos/staging-x86_64/0001-libarchive-Handle-a-calloc-returning-NULL-fixes-1754.patch
 (from rev 459781, 
libarchive/trunk/0001-libarchive-Handle-a-calloc-returning-NULL-fixes-1754.patch)
===================================================================
--- 
staging-x86_64/0001-libarchive-Handle-a-calloc-returning-NULL-fixes-1754.patch  
                            (rev 0)
+++ 
staging-x86_64/0001-libarchive-Handle-a-calloc-returning-NULL-fixes-1754.patch  
    2022-11-01 11:27:45 UTC (rev 459782)
@@ -0,0 +1,35 @@
+From bff38efe8c110469c5080d387bec62a6ca15b1a5 Mon Sep 17 00:00:00 2001
+From: obiwac <[email protected]>
+Date: Fri, 22 Jul 2022 22:41:10 +0200
+Subject: [PATCH] libarchive: Handle a `calloc` returning NULL (fixes #1754)
+
+---
+ libarchive/archive_write.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/libarchive/archive_write.c b/libarchive/archive_write.c
+index 66592e82..27626b54 100644
+--- a/libarchive/archive_write.c
++++ b/libarchive/archive_write.c
+@@ -201,6 +201,10 @@ __archive_write_allocate_filter(struct archive *_a)
+       struct archive_write_filter *f;
+ 
+       f = calloc(1, sizeof(*f));
++
++      if (f == NULL)
++              return (NULL);
++
+       f->archive = _a;
+       f->state = ARCHIVE_WRITE_FILTER_STATE_NEW;
+       if (a->filter_first == NULL)
+@@ -548,6 +552,10 @@ archive_write_open2(struct archive *_a, void *client_data,
+       a->client_data = client_data;
+ 
+       client_filter = __archive_write_allocate_filter(_a);
++
++      if (client_filter == NULL)
++              return (ARCHIVE_FATAL);
++
+       client_filter->open = archive_write_client_open;
+       client_filter->write = archive_write_client_write;
+       client_filter->close = archive_write_client_close;

Copied: 
libarchive/repos/staging-x86_64/0002-Validate-entry_bytes_remaining-in-pax_attribute.patch
 (from rev 459781, 
libarchive/trunk/0002-Validate-entry_bytes_remaining-in-pax_attribute.patch)
===================================================================
--- staging-x86_64/0002-Validate-entry_bytes_remaining-in-pax_attribute.patch   
                        (rev 0)
+++ staging-x86_64/0002-Validate-entry_bytes_remaining-in-pax_attribute.patch   
2022-11-01 11:27:45 UTC (rev 459782)
@@ -0,0 +1,42 @@
+From fc8c6d2786ecba731d77d33fe3b034f581fcbde3 Mon Sep 17 00:00:00 2001
+From: Ben Wagner <[email protected]>
+Date: Tue, 19 Jul 2022 13:02:40 -0400
+Subject: [PATCH] Validate entry_bytes_remaining in pax_attribute
+
+The `size` attribute may contain a negative or too large value. Check
+the range of the `entry_bytes_remaining` in `pax_attribute` the same way
+as `header_common`. The test which is added passes both with and without
+this change in a normal debug build. It is necessary to run with
+`-fsanitize=undefined` to see that the undefined behavior is avoided.
+
+Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=48467
+---
+ libarchive/archive_read_support_format_tar.c  | 15 ++++++
+ 1 files changed, 15 insertions(+)
+
+diff --git a/libarchive/archive_read_support_format_tar.c 
b/libarchive/archive_read_support_format_tar.c
+index bfdad7f8..e31f1cc4 100644
+--- a/libarchive/archive_read_support_format_tar.c
++++ b/libarchive/archive_read_support_format_tar.c
+@@ -2108,6 +2108,21 @@ pax_attribute(struct archive_read *a, struct tar *tar,
+                       /* "size" is the size of the data in the entry. */
+                       tar->entry_bytes_remaining
+                           = tar_atol10(value, strlen(value));
++                      if (tar->entry_bytes_remaining < 0) {
++                              tar->entry_bytes_remaining = 0;
++                              archive_set_error(&a->archive,
++                                  ARCHIVE_ERRNO_MISC,
++                                  "Tar size attribute is negative");
++                              return (ARCHIVE_FATAL);
++                      }
++                      if (tar->entry_bytes_remaining == INT64_MAX) {
++                              /* Note: tar_atol returns INT64_MAX on overflow 
*/
++                              tar->entry_bytes_remaining = 0;
++                              archive_set_error(&a->archive,
++                                  ARCHIVE_ERRNO_MISC,
++                                  "Tar size attribute overflow");
++                              return (ARCHIVE_FATAL);
++                      }
+                       /*
+                        * The "size" pax header keyword always overrides the
+                        * "size" field in the tar header.

Copied: 
libarchive/repos/staging-x86_64/0003-libarchive-Do-not-include-sys-mount.h-when-linux-fs..patch
 (from rev 459781, 
libarchive/trunk/0003-libarchive-Do-not-include-sys-mount.h-when-linux-fs..patch)
===================================================================
--- 
staging-x86_64/0003-libarchive-Do-not-include-sys-mount.h-when-linux-fs..patch  
                            (rev 0)
+++ 
staging-x86_64/0003-libarchive-Do-not-include-sys-mount.h-when-linux-fs..patch  
    2022-11-01 11:27:45 UTC (rev 459782)
@@ -0,0 +1,40 @@
+From a2f68263a1da5ad227bcb9cd8fa91b93c8b6c99f Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Mon, 25 Jul 2022 10:56:53 -0700
+Subject: [PATCH] libarchive: Do not include sys/mount.h when linux/fs.h is 
present
+
+These headers are in conflict and only one is needed by
+archive_read_disk_posix.c therefore include linux/fs.h if it exists
+otherwise include sys/mount.h
+
+It also helps compiling with glibc 2.36
+where sys/mount.h conflicts with linux/mount.h see [1]
+
+[1] https://sourceware.org/glibc/wiki/Release/2.36
+---
+ libarchive/archive_read_disk_posix.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/libarchive/archive_read_disk_posix.c 
b/libarchive/archive_read_disk_posix.c
+index 2b39e672..a96008db 100644
+--- a/libarchive/archive_read_disk_posix.c
++++ b/libarchive/archive_read_disk_posix.c
+@@ -34,9 +34,6 @@ __FBSDID("$FreeBSD$");
+ #ifdef HAVE_SYS_PARAM_H
+ #include <sys/param.h>
+ #endif
+-#ifdef HAVE_SYS_MOUNT_H
+-#include <sys/mount.h>
+-#endif
+ #ifdef HAVE_SYS_STAT_H
+ #include <sys/stat.h>
+ #endif
+@@ -54,6 +51,8 @@ __FBSDID("$FreeBSD$");
+ #endif
+ #ifdef HAVE_LINUX_FS_H
+ #include <linux/fs.h>
++#elif HAVE_SYS_MOUNT_H
++#include <sys/mount.h>
+ #endif
+ /*
+  * Some Linux distributions have both linux/ext2_fs.h and ext2fs/ext2_fs.h.

Copied: libarchive/repos/staging-x86_64/PKGBUILD (from rev 459781, 
libarchive/trunk/PKGBUILD)
===================================================================
--- staging-x86_64/PKGBUILD                             (rev 0)
+++ staging-x86_64/PKGBUILD     2022-11-01 11:27:45 UTC (rev 459782)
@@ -0,0 +1,55 @@
+# Maintainer: BartÅ‚omiej Piotrowski <[email protected]>
+# Maintainer: Dan McGee <[email protected]>
+
+pkgname=libarchive
+pkgver=3.6.1
+pkgrel=3
+pkgdesc='Multi-format archive and compression library'
+arch=('x86_64')
+url='https://libarchive.org/'
+license=('BSD')
+depends=('acl' 'libacl.so' 'bzip2' 'expat' 'lz4' 'openssl' 'xz' 'zlib' 'zstd')
+provides=('libarchive.so')
+options=('debug')
+validpgpkeys=('A5A45B12AD92D964B89EEE2DEC560C81CEC2276E') # Martin Matuska 
<[email protected]>
+source=("https://github.com/${pkgname}/${pkgname}/releases/download/v${pkgver}/${pkgname}-${pkgver}.tar.xz"{,.asc}
+        '0001-libarchive-Handle-a-calloc-returning-NULL-fixes-1754.patch'
+        '0002-Validate-entry_bytes_remaining-in-pax_attribute.patch'
+        '0003-libarchive-Do-not-include-sys-mount.h-when-linux-fs..patch')
+sha256sums=('5a411aceb978f43e626f0c2d1812ddd8807b645ed892453acabd532376c148e6'
+            'SKIP'
+            'bc52b2b2b99915894b436c97872d5d50e94c8c7483865a028fad9a710c837fa7'
+            '38c8d9b00f3259558e67e6fdf790ccbf8ecbba2de101476c2416d87b1679bcb9'
+            '99c85a9b8e6c16131cefaf1040d5fa15cd565ecf8c71c1f644c8fa47fe1306dc')
+
+prepare() {
+  cd "${pkgname}-${pkgver}"
+
+  patch -Np1 < 
../0001-libarchive-Handle-a-calloc-returning-NULL-fixes-1754.patch
+  patch -Np1 < ../0002-Validate-entry_bytes_remaining-in-pax_attribute.patch
+  patch -Np1 < 
../0003-libarchive-Do-not-include-sys-mount.h-when-linux-fs..patch
+}
+
+build() {
+  cd "${pkgname}-${pkgver}"
+
+  ./configure \
+      --prefix=/usr \
+      --without-xml2 \
+      --without-nettle \
+      --disable-static
+  make
+}
+
+check() {
+  cd "${pkgname}-${pkgver}"
+
+  make check
+}
+
+package() {
+  cd "${pkgname}-${pkgver}"
+
+  make DESTDIR="$pkgdir" install
+  install -Dm0644 COPYING "$pkgdir/usr/share/licenses/libarchive/COPYING"
+}

Reply via email to