diff options
author | kientzle <kientzle@FreeBSD.org> | 2004-06-07 06:34:51 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2004-06-07 06:34:51 +0000 |
commit | 5707dd1fa57f288b64c281391afd809c567d1c2e (patch) | |
tree | 86befdac4ca2c38dd23d062ab8d03d1a79778ebd | |
parent | f873013198d189aa7cc21ef04e796238995405c1 (diff) | |
download | FreeBSD-src-5707dd1fa57f288b64c281391afd809c567d1c2e.zip FreeBSD-src-5707dd1fa57f288b64c281391afd809c567d1c2e.tar.gz |
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
-rw-r--r-- | lib/libarchive/archive_read_support_format_tar.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/libarchive/archive_read_support_format_tar.c b/lib/libarchive/archive_read_support_format_tar.c index a68eb39..014ba6c 100644 --- a/lib/libarchive/archive_read_support_format_tar.c +++ b/lib/libarchive/archive_read_support_format_tar.c @@ -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); |