Skip to content

Commit

Permalink
Do not overwrite pathname in header_old_tar() if already
Browse files Browse the repository at this point in the history
set in header_gnu_longname()
  • Loading branch information
mmatuska committed Oct 6, 2024
1 parent 75cdc59 commit 661ee10
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions libarchive/archive_read_support_format_tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1521,9 +1521,17 @@ header_old_tar(struct archive_read *a, struct tar *tar,
const struct archive_entry_header_ustar *header;
int err = ARCHIVE_OK, err2;

/* Copy filename over (to ensure null termination). */
/*
* Copy filename over (to ensure null termination).
* Skip if pathname was already set e.g. by header_gnu_longname()
*/
header = (const struct archive_entry_header_ustar *)h;
if (archive_entry_copy_pathname_l(entry,

const char *existing_pathname = archive_entry_pathname(entry);
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_entry_copy_pathname_l(entry,
header->name, sizeof(header->name), tar->sconv) != 0) {
err = set_conversion_failed_error(a, tar->sconv, "Pathname");
if (err == ARCHIVE_FATAL)
Expand Down

0 comments on commit 661ee10

Please sign in to comment.