From a11b570001fc307f14a4ed084e6e414e6eccf692 Mon Sep 17 00:00:00 2001 From: Duncan Horn Date: Tue, 11 Jun 2024 13:26:20 -0700 Subject: [PATCH] Read 7zip symlink names as UTF-8 --- libarchive/archive_read_support_format_7zip.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libarchive/archive_read_support_format_7zip.c b/libarchive/archive_read_support_format_7zip.c index 634521d95..686ba1762 100644 --- a/libarchive/archive_read_support_format_7zip.c +++ b/libarchive/archive_read_support_format_7zip.c @@ -835,9 +835,20 @@ archive_read_format_7zip_read_header(struct archive_read *a, zip_entry->mode |= AE_IFREG; archive_entry_set_mode(entry, zip_entry->mode); } else { + struct archive_string_conv* utf8_conv; + symname[symsize] = '\0'; - archive_entry_copy_symlink(entry, - (const char *)symname); + + /* Symbolic links are embedded as UTF-8 strings */ + utf8_conv = archive_string_conversion_from_charset(&a->archive, + "UTF-8", 1); + if (utf8_conv == NULL) { + free(symname); + return ARCHIVE_FATAL; + } + + archive_entry_copy_symlink_l(entry, (const char*)symname, symsize, + utf8_conv); } free(symname); archive_entry_set_size(entry, 0);