libarchive: update to 3.4.1.
This commit is contained in:
parent
f9f7195e57
commit
ac7098156a
2 changed files with 4 additions and 102 deletions
|
@ -1,97 +0,0 @@
|
|||
From 22b1db9d46654afc6f0c28f90af8cdc84a199f41 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Matuska <martin@matuska.org>
|
||||
Date: Thu, 21 Nov 2019 03:08:40 +0100
|
||||
Subject: [PATCH] Bugfix and optimize archive_wstring_append_from_mbs()
|
||||
|
||||
The cal to mbrtowc() or mbtowc() should read up to mbs_length
|
||||
bytes and not wcs_length. This avoids out-of-bounds reads.
|
||||
|
||||
mbrtowc() and mbtowc() return (size_t)-1 wit errno EILSEQ when
|
||||
they encounter an invalid multibyte character and (size_t)-2 when
|
||||
they they encounter an incomplete multibyte character. As we return
|
||||
failure and all our callers error out it makes no sense to continue
|
||||
parsing mbs.
|
||||
|
||||
As we allocate `len` wchars at the beginning and each wchar has
|
||||
at least one byte, there will never be need to grow the buffer,
|
||||
so the code can be left out. On the other hand, we are always
|
||||
allocatng more memory than we need.
|
||||
|
||||
As long as wcs_length == mbs_length == len we can omit wcs_length.
|
||||
We keep the old code commented if we decide to save memory and
|
||||
use autoexpanding wcs_length in the future.
|
||||
|
||||
Fixes #1276
|
||||
---
|
||||
libarchive/archive_string.c | 28 +++++++++++++++++-----------
|
||||
1 file changed, 17 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git libarchive/archive_string.c libarchive/archive_string.c
|
||||
index 979a418b6..bd39c96f1 100644
|
||||
--- libarchive/archive_string.c
|
||||
+++ libarchive/archive_string.c
|
||||
@@ -591,7 +591,7 @@ archive_wstring_append_from_mbs(struct archive_wstring *dest,
|
||||
* No single byte will be more than one wide character,
|
||||
* so this length estimate will always be big enough.
|
||||
*/
|
||||
- size_t wcs_length = len;
|
||||
+ // size_t wcs_length = len;
|
||||
size_t mbs_length = len;
|
||||
const char *mbs = p;
|
||||
wchar_t *wcs;
|
||||
@@ -600,7 +600,11 @@ archive_wstring_append_from_mbs(struct archive_wstring *dest,
|
||||
|
||||
memset(&shift_state, 0, sizeof(shift_state));
|
||||
#endif
|
||||
- if (NULL == archive_wstring_ensure(dest, dest->length + wcs_length + 1))
|
||||
+ /*
|
||||
+ * As we decided to have wcs_length == mbs_length == len
|
||||
+ * we can use len here instead of wcs_length
|
||||
+ */
|
||||
+ if (NULL == archive_wstring_ensure(dest, dest->length + len + 1))
|
||||
return (-1);
|
||||
wcs = dest->s + dest->length;
|
||||
/*
|
||||
@@ -609,6 +613,12 @@ archive_wstring_append_from_mbs(struct archive_wstring *dest,
|
||||
* multi bytes.
|
||||
*/
|
||||
while (*mbs && mbs_length > 0) {
|
||||
+ /*
|
||||
+ * The buffer we allocated is always big enough.
|
||||
+ * Keep this code path in a comment if we decide to choose
|
||||
+ * smaller wcs_length in the future
|
||||
+ */
|
||||
+/*
|
||||
if (wcs_length == 0) {
|
||||
dest->length = wcs - dest->s;
|
||||
dest->s[dest->length] = L'\0';
|
||||
@@ -618,24 +628,20 @@ archive_wstring_append_from_mbs(struct archive_wstring *dest,
|
||||
return (-1);
|
||||
wcs = dest->s + dest->length;
|
||||
}
|
||||
+*/
|
||||
#if HAVE_MBRTOWC
|
||||
- r = mbrtowc(wcs, mbs, wcs_length, &shift_state);
|
||||
+ r = mbrtowc(wcs, mbs, mbs_length, &shift_state);
|
||||
#else
|
||||
- r = mbtowc(wcs, mbs, wcs_length);
|
||||
+ r = mbtowc(wcs, mbs, mbs_length);
|
||||
#endif
|
||||
if (r == (size_t)-1 || r == (size_t)-2) {
|
||||
ret_val = -1;
|
||||
- if (errno == EILSEQ) {
|
||||
- ++mbs;
|
||||
- --mbs_length;
|
||||
- continue;
|
||||
- } else
|
||||
- break;
|
||||
+ break;
|
||||
}
|
||||
if (r == 0 || r > mbs_length)
|
||||
break;
|
||||
wcs++;
|
||||
- wcs_length--;
|
||||
+ // wcs_length--;
|
||||
mbs += r;
|
||||
mbs_length -= r;
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
# Template file for 'libarchive'
|
||||
pkgname=libarchive
|
||||
version=3.4.0
|
||||
revision=2
|
||||
version=3.4.1
|
||||
revision=1
|
||||
bootstrap=yes
|
||||
build_style=gnu-configure
|
||||
configure_args="$(vopt_enable acl) $(vopt_enable acl xattr)
|
||||
|
@ -12,15 +12,14 @@ makedepends="zlib-devel bzip2-devel liblzma-devel
|
|||
$(vopt_if acl acl-devel) $(vopt_if expat expat-devel) $(vopt_if zstd libzstd-devel)
|
||||
$(vopt_if lzo lzo-devel) $(vopt_if lz4 liblz4-devel) $(vopt_if ssl libressl-devel)"
|
||||
short_desc="Library to read/write several different streaming archive formats"
|
||||
maintainer="Orphaned <orphan@voidlinux.org>"
|
||||
maintainer="Juan RP <xtraeme@gmail.com>"
|
||||
license="BSD-2-Clause"
|
||||
homepage="http://www.libarchive.org/"
|
||||
distfiles="https://github.com/libarchive/libarchive/releases/download/v${version}/libarchive-${version}.tar.gz"
|
||||
checksum=8643d50ed40c759f5412a3af4e353cffbce4fdf3b5cf321cb72cacf06b2d825e
|
||||
checksum=fcf87f3ad8db2e4f74f32526dee62dd1fb9894782b0a503a89c9d7a70a235191
|
||||
|
||||
# Package build options
|
||||
build_options="acl expat lzo lz4 ssl zstd"
|
||||
# Enable acl, ssl, lz4 and zstd by default.
|
||||
build_options_default="acl ssl lz4 zstd"
|
||||
|
||||
if [ "$CHROOT_READY" ]; then
|
||||
|
|
Loading…
Reference in a new issue