Skip to content

Commit

Permalink
Do not overwrite WCS link paths either
Browse files Browse the repository at this point in the history
  • Loading branch information
kientzle committed Jul 8, 2024
1 parent 8d74786 commit 1a6c7a8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions libarchive/archive_read_support_format_tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,7 @@ header_common(struct archive_read *a, struct tar *tar,
{
const struct archive_entry_header_ustar *header;
const char *existing_linkpath;
const wchar_t *existing_wcs_linkpath;
int err = ARCHIVE_OK;

header = (const struct archive_entry_header_ustar *)h;
Expand Down Expand Up @@ -1346,8 +1347,10 @@ header_common(struct archive_read *a, struct tar *tar,
switch (tar->filetype) {
case '1': /* Hard link */
archive_entry_set_link_to_hardlink(entry);
existing_wcs_linkpath = archive_entry_hardlink_w(entry);
existing_linkpath = archive_entry_hardlink(entry);
if (existing_linkpath == NULL || existing_linkpath[0] == '\0') {
if ((existing_linkpath == NULL || existing_linkpath[0] == '\0')
&& (existing_wcs_linkpath == NULL || existing_wcs_linkpath[0] == '\0')) {
struct archive_string linkpath;
archive_string_init(&linkpath);
archive_strncpy(&linkpath,
Expand Down Expand Up @@ -1422,8 +1425,10 @@ header_common(struct archive_read *a, struct tar *tar,
break;
case '2': /* Symlink */
archive_entry_set_link_to_symlink(entry);
existing_linkpath = archive_entry_symlink(entry);
if (existing_linkpath == NULL || existing_linkpath[0] == '\0') {
existing_wcs_linkpath = archive_entry_hardlink_w(entry);
existing_linkpath = archive_entry_hardlink(entry);
if ((existing_linkpath == NULL || existing_linkpath[0] == '\0')
&& (existing_wcs_linkpath == NULL || existing_wcs_linkpath[0] == '\0')) {
struct archive_string linkpath;
archive_string_init(&linkpath);
archive_strncpy(&linkpath,
Expand Down

0 comments on commit 1a6c7a8

Please sign in to comment.