History: A few very, very old tar programs used the filename to
distinguish files from dirs (trailing '/' indicated a dir). Since POSIX.1-1987, this convention is no longer necessary. However, there are current tar programs that pretend to write POSIX-compliant archives, yet store directories as "regular files", relying on this old filename convention to save them. <sigh> So, move the check for this old convention so it applies to all tar archives, not just those identified as "old." Pointed out by: Broken distfile for audio/faad port
This commit is contained in:
parent
bbc8ceda71
commit
33e546958b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=130175
@ -337,6 +337,8 @@ tar_read_header(struct archive *a, struct tar *tar,
|
||||
ssize_t bytes;
|
||||
int err;
|
||||
const void *h;
|
||||
const char *p;
|
||||
size_t l;
|
||||
const struct archive_entry_header_ustar *header;
|
||||
|
||||
/* Read 512-byte header record */
|
||||
@ -427,6 +429,14 @@ tar_read_header(struct archive *a, struct tar *tar,
|
||||
a->archive_format_name = "tar (non-POSIX)";
|
||||
err = header_old_tar(a, tar, entry, st, h);
|
||||
}
|
||||
|
||||
/* "Regular" entry with trailing '/' is really directory. */
|
||||
p = archive_entry_pathname(entry);
|
||||
l = strlen(p);
|
||||
if (S_ISREG(st->st_mode) && p[l-1] == '/') {
|
||||
st->st_mode &= ~S_IFMT;
|
||||
st->st_mode |= S_IFDIR;
|
||||
}
|
||||
}
|
||||
archive_entry_copy_stat(entry, st);
|
||||
--tar->header_recursion_depth;
|
||||
@ -772,18 +782,6 @@ header_old_tar(struct archive *a, struct tar *tar, struct archive_entry *entry,
|
||||
/* Grab rest of common fields */
|
||||
header_common(a, tar, entry, st, h);
|
||||
|
||||
/*
|
||||
* TODO: Decide whether the following special handling
|
||||
* is needed for POSIX headers. Factor accordingly.
|
||||
*/
|
||||
|
||||
/* "Regular" entry with trailing '/' is really directory. */
|
||||
if (S_ISREG(st->st_mode) &&
|
||||
'/' == tar->entry_name.s[strlen(tar->entry_name.s) - 1]) {
|
||||
st->st_mode &= ~S_IFMT;
|
||||
st->st_mode |= S_IFDIR;
|
||||
}
|
||||
|
||||
tar->entry_bytes_remaining = st->st_size;
|
||||
tar->entry_padding = 0x1ff & (-tar->entry_bytes_remaining);
|
||||
return (0);
|
||||
|
Loading…
Reference in New Issue
Block a user