summaryrefslogtreecommitdiff
path: root/archival/libunarchive
diff options
context:
space:
mode:
authorGlenn L McGrath2002-08-13 05:06:43 +0000
committerGlenn L McGrath2002-08-13 05:06:43 +0000
commit1d23f3a492ecc18b3e406d814a55c93bb8917e0e (patch)
treed54376d977df67e05d11e4388245bd532936a9d5 /archival/libunarchive
parent6069441bd20b24f7102ebd66f9373a4de0d7e92c (diff)
downloadbusybox-1d23f3a492ecc18b3e406d814a55c93bb8917e0e.zip
busybox-1d23f3a492ecc18b3e406d814a55c93bb8917e0e.tar.gz
Enable support for the old tar header format, enable via menu's
Diffstat (limited to 'archival/libunarchive')
-rw-r--r--archival/libunarchive/get_header_tar.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c
index be6bf2a..07b9ae3 100644
--- a/archival/libunarchive/get_header_tar.c
+++ b/archival/libunarchive/get_header_tar.c
@@ -60,11 +60,18 @@ file_header_t *get_header_tar(FILE *tar_stream)
}
archive_offset += 512;
- /* Check header has valid magic, unfortunately some tar files
- * have empty (0'ed) tar entries at the end, which will
- * cause this to fail, so fail silently for now
+ /* Check header has valid magic, "ustar" is for the proper tar
+ * 0's are for the old tar format
*/
if (strncmp(tar.formated.magic, "ustar", 5) != 0) {
+#ifdef CONFIG_FEATURE_TAR_OLD_FORMAT
+ if (strncmp(tar.formated.magic, "\0\0\0\0\0", 5) != 0)
+#endif
+ return(NULL);
+ }
+
+ /* If there is no filename its an empty header, skip it */
+ if (xstrlen(tar.formated.name) == 0) {
return(NULL);
}
@@ -85,7 +92,32 @@ file_header_t *get_header_tar(FILE *tar_stream)
tar_entry = xcalloc(1, sizeof(file_header_t));
tar_entry->name = xstrdup(tar.formated.name);
- parse_mode(tar.formated.mode, &tar_entry->mode);
+ tar_entry->mode = strtol(tar.formated.mode, NULL, 8);
+#ifdef CONFIG_FEATURE_TAR_OLD_FORMAT
+ switch (tar.formated.typeflag) {
+ case 0:
+ tar_entry->mode |= S_IFREG;
+ break;
+ case 1:
+ error_msg("internal hard link not handled\n");
+ break;
+ case 2:
+ tar_entry->mode |= S_IFLNK;
+ break;
+ case 3:
+ tar_entry->mode |= S_IFCHR;
+ break;
+ case 4:
+ tar_entry->mode |= S_IFBLK;
+ break;
+ case 5:
+ tar_entry->mode |= S_IFDIR;
+ break;
+ case 6:
+ tar_entry->mode |= S_IFIFO;
+ break;
+ }
+#endif
tar_entry->uid = strtol(tar.formated.uid, NULL, 8);
tar_entry->gid = strtol(tar.formated.gid, NULL, 8);
tar_entry->size = strtol(tar.formated.size, NULL, 8);