1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-18 15:30:21 +00:00

When combining ustar prefix and name fields, check before adding a '/'

character, as some tar implementations incorrectly include a '/' with
the prefix.

Thanks to: Divacky Roman for the UnixWare 7 tarfile that
demonstrated this issue.
This commit is contained in:
Tim Kientzle 2004-05-19 17:09:24 +00:00
parent 8693960479
commit 22a2730797
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=129447

View File

@ -764,21 +764,21 @@ header_ustar(struct archive *a, struct tar *tar, struct archive_entry *entry,
struct stat *st, const void *h)
{
const struct archive_entry_header_ustar *header;
struct archive_string *as;
header = h;
/* Copy name into an internal buffer to ensure null-termination. */
as = &(tar->entry_name);
if (header->prefix[0]) {
archive_strncpy(&(tar->entry_name), header->prefix,
sizeof(header->prefix));
archive_strappend_char(&(tar->entry_name), '/');
archive_strncat(&(tar->entry_name), header->name,
sizeof(header->name));
archive_strncpy(as, header->prefix, sizeof(header->prefix));
if (as->s[archive_strlen(as) - 1] != '/')
archive_strappend_char(as, '/');
archive_strncat(as, header->name, sizeof(header->name));
} else
archive_strncpy(&(tar->entry_name), header->name,
sizeof(header->name));
archive_strncpy(as, header->name, sizeof(header->name));
archive_entry_set_pathname(entry, tar->entry_name.s);
archive_entry_set_pathname(entry, as->s);
/* Handle rest of common fields. */
header_common(a, tar, entry, st, h);