From: Tim Kientzle Date: Sat, 4 Oct 2025 03:43:21 +0000 (-0700) Subject: Merge pull request #2740 from dunhor/gnutar_longpath_unicode X-Git-Tag: v3.8.2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=400abd1d7f3364f673fa6dad33bfb2d33de661ab;p=thirdparty%2Flibarchive.git Merge pull request #2740 from dunhor/gnutar_longpath_unicode Check WCS pathname in header_gnutar before overwriting (cherry picked from commit fda50c79ba9fb02dbdfda3f60e4fd3ef399e738f) --- diff --git a/libarchive/archive_read_support_format_tar.c b/libarchive/archive_read_support_format_tar.c index cb5344d60..37fdd2ce7 100644 --- a/libarchive/archive_read_support_format_tar.c +++ b/libarchive/archive_read_support_format_tar.c @@ -2940,7 +2940,9 @@ header_gnutar(struct archive_read *a, struct tar *tar, /* Copy filename over (to ensure null termination). */ header = (const struct archive_entry_header_gnutar *)h; const char *existing_pathname = archive_entry_pathname(entry); - if (existing_pathname == NULL || existing_pathname[0] == '\0') { + const wchar_t *existing_wcs_pathname = archive_entry_pathname_w(entry); + if ((existing_pathname == NULL || existing_pathname[0] == '\0') + && (existing_wcs_pathname == NULL || existing_wcs_pathname[0] == L'\0')) { if (archive_entry_copy_pathname_l(entry, header->name, sizeof(header->name), tar->sconv) != 0) { err = set_conversion_failed_error(a, tar->sconv, "Pathname");