summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Matuška <martin@matuska.org>2022-12-06 12:10:48 +0100
committerGitHub <noreply@github.com>2022-12-06 12:10:48 +0100
commit06a4b1018ee843cd491f6ff92813e67962fa0335 (patch)
treecb963da4ff55015835674024e63503af6600ab6f
parent6bea1a69c970a94f5332f89692ac8168c2400342 (diff)
parentd6248d2640efe3e40a1a9c0bb7bd8903f6beef98 (diff)
downloadlibarchive-06a4b1018ee843cd491f6ff92813e67962fa0335.tar.gz
Merge pull request #1772 from bgermann/master
archive_entry_pathname() tries UTF-8 if MBS returns EILSEQ
-rw-r--r--libarchive/archive_entry.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/libarchive/archive_entry.c b/libarchive/archive_entry.c
index ca7a4bdb..ae6dc333 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);