From 8d74786f4425ad180961cc5130902ddd055ea869 Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Sun, 7 Jul 2024 17:50:03 -0700 Subject: [PATCH] Do not overwrite an existing WCS pathname either --- libarchive/archive_read_support_format_tar.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libarchive/archive_read_support_format_tar.c b/libarchive/archive_read_support_format_tar.c index 65d7a3d3d2..9509e01e3f 100644 --- a/libarchive/archive_read_support_format_tar.c +++ b/libarchive/archive_read_support_format_tar.c @@ -1677,7 +1677,9 @@ header_ustar(struct archive_read *a, struct tar *tar, /* Copy name into an internal buffer to ensure null-termination. */ 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] == '\0')) { archive_string_init(&as); if (header->prefix[0]) { archive_strncpy(&as, header->prefix, sizeof(header->prefix));