diff options
Diffstat (limited to 'archivers/libarchive/files/libarchive/archive_write_set_format_pax.c')
-rw-r--r-- | archivers/libarchive/files/libarchive/archive_write_set_format_pax.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_format_pax.c b/archivers/libarchive/files/libarchive/archive_write_set_format_pax.c index 3cebeae187d..cf2a1f959e3 100644 --- a/archivers/libarchive/files/libarchive/archive_write_set_format_pax.c +++ b/archivers/libarchive/files/libarchive/archive_write_set_format_pax.c @@ -522,11 +522,13 @@ add_pax_acl(struct archive_write *a, ARCHIVE_ERRNO_FILE_FORMAT, "%s %s %s", "Can't translate ", attr, " to UTF-8"); return(ARCHIVE_WARN); - } else if (*p != '\0') { + } + + if (*p != '\0') { add_pax_attr(&(pax->pax_header), attr, p); - free(p); } + free(p); return(ARCHIVE_OK); } @@ -660,7 +662,7 @@ archive_write_pax_header(struct archive_write *a, * case getting WCS failed. On POSIX, this is a * normal operation. */ - if (p != NULL && p[strlen(p) - 1] != '/') { + if (p != NULL && p[0] != '\0' && p[strlen(p) - 1] != '/') { struct archive_string as; archive_string_init(&as); @@ -1112,6 +1114,10 @@ archive_write_pax_header(struct archive_write *a, if (!need_extension && acl_types != 0) need_extension = 1; + /* If the symlink type is defined, we need an extension */ + if (!need_extension && archive_entry_symlink_type(entry_main) > 0) + need_extension = 1; + /* * Libarchive used to include these in extended headers for * restricted pax format, but that confused people who @@ -1245,6 +1251,17 @@ archive_write_pax_header(struct archive_write *a, archive_string_free(&entry_name); return (ARCHIVE_FATAL); } + + /* Store extended symlink information */ + if (archive_entry_symlink_type(entry_main) == + AE_SYMLINK_TYPE_FILE) { + add_pax_attr(&(pax->pax_header), + "LIBARCHIVE.symlinktype", "file"); + } else if (archive_entry_symlink_type(entry_main) == + AE_SYMLINK_TYPE_DIRECTORY) { + add_pax_attr(&(pax->pax_header), + "LIBARCHIVE.symlinktype", "dir"); + } } /* Only regular files have data. */ |