Backport upstream PR for better pathname portability across OS

This commit is contained in:
Davide Cavalca 2022-10-21 21:33:03 -07:00
parent 91afc68c1a
commit 9082c0b67e
2 changed files with 53 additions and 1 deletions

View File

@ -0,0 +1,44 @@
From d6248d2640efe3e40a1a9c0bb7bd8903f6beef98 Mon Sep 17 00:00:00 2001
From: John Reiser <jreiser@BitWagon.com>
Date: Fri, 26 Aug 2022 09:51:19 -0700
Subject: [PATCH] archive_entry_pathname() tries UTF-8 if MBS returns EILSEQ
For better pathname portability across OS, in particular Windows to Linux.
Original bug: unrar in https://bugzilla.redhat.com/show_bug.cgi?id=2120926
modified: libarchive/archive_entry.c
---
libarchive/archive_entry.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/libarchive/archive_entry.c b/libarchive/archive_entry.c
index ca7a4bdb5..ae6dc3336 100644
--- a/libarchive/archive_entry.c
+++ b/libarchive/archive_entry.c
@@ -568,6 +568,13 @@ archive_entry_nlink(struct archive_entry *entry)
return (entry->ae_stat.aest_nlink);
}
+/* Instead, our caller could have chosen a specific encoding
+ * (archive_mstring_get_mbs, archive_mstring_get_utf8,
+ * archive_mstring_get_wcs). So we should try multiple
+ * encodings. Try mbs first because of history, even though
+ * utf8 might be better for pathname portability.
+ * Also omit wcs because of type mismatch (char * versus wchar *)
+ */
const char *
archive_entry_pathname(struct archive_entry *entry)
{
@@ -575,6 +582,13 @@ archive_entry_pathname(struct archive_entry *entry)
if (archive_mstring_get_mbs(
entry->archive, &entry->ae_pathname, &p) == 0)
return (p);
+#if HAVE_EILSEQ /*{*/
+ if (errno == EILSEQ) {
+ if (archive_mstring_get_utf8(
+ entry->archive, &entry->ae_pathname, &p) == 0)
+ return (p);
+ }
+#endif /*}*/
if (errno == ENOMEM)
__archive_errx(1, "No memory");
return (NULL);

View File

@ -2,7 +2,7 @@
Name: libarchive Name: libarchive
Version: 3.6.1 Version: 3.6.1
Release: 4%{?dist} Release: 5%{?dist}
Summary: A library for handling streaming archive formats Summary: A library for handling streaming archive formats
License: BSD License: BSD
@ -41,6 +41,10 @@ Patch0001: 0001-Drop-rmd160-from-OpenSSL.patch
# Source: https://github.com/libarchive/libarchive/commit/fd180c36036df7181a64931264732a10ad8cd024 # Source: https://github.com/libarchive/libarchive/commit/fd180c36036df7181a64931264732a10ad8cd024
Patch2: %{name}-3.6.1-Fix-CVE-2022-36227.patch Patch2: %{name}-3.6.1-Fix-CVE-2022-36227.patch
# For better pathname portability across OS, in particular Windows to Linux
# archive_entry_pathname() tries UTF-8 if MBS returns EILSEQ
# Source: https://github.com/libarchive/libarchive/commit/06a4b1018ee843cd491f6ff92813e67962fa0335
Patch3: %{name}-3.6.1-Better-pathname-portability.patch
%description %description
Libarchive is a programming library that can create and read several different Libarchive is a programming library that can create and read several different
@ -225,6 +229,10 @@ run_testsuite
%changelog %changelog
* Wed Feb 08 2023 Davide Cavalca <dcavalca@fedoraproject.org> - 3.6.1-5
- Backport upstream PR#1772 for better pathname portability across OS
Resolves: #2136961
* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3.6.1-4 * Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3.6.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild