diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2002-08-13 05:06:43 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2002-08-13 05:06:43 +0000 |
commit | 1d23f3a492ecc18b3e406d814a55c93bb8917e0e (patch) | |
tree | d54376d977df67e05d11e4388245bd532936a9d5 /archival/libunarchive | |
parent | 6069441bd20b24f7102ebd66f9373a4de0d7e92c (diff) | |
download | busybox-w32-1d23f3a492ecc18b3e406d814a55c93bb8917e0e.tar.gz busybox-w32-1d23f3a492ecc18b3e406d814a55c93bb8917e0e.tar.bz2 busybox-w32-1d23f3a492ecc18b3e406d814a55c93bb8917e0e.zip |
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.c | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c index be6bf2a06..07b9ae36f 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) | |||
60 | } | 60 | } |
61 | archive_offset += 512; | 61 | archive_offset += 512; |
62 | 62 | ||
63 | /* Check header has valid magic, unfortunately some tar files | 63 | /* Check header has valid magic, "ustar" is for the proper tar |
64 | * have empty (0'ed) tar entries at the end, which will | 64 | * 0's are for the old tar format |
65 | * cause this to fail, so fail silently for now | ||
66 | */ | 65 | */ |
67 | if (strncmp(tar.formated.magic, "ustar", 5) != 0) { | 66 | if (strncmp(tar.formated.magic, "ustar", 5) != 0) { |
67 | #ifdef CONFIG_FEATURE_TAR_OLD_FORMAT | ||
68 | if (strncmp(tar.formated.magic, "\0\0\0\0\0", 5) != 0) | ||
69 | #endif | ||
70 | return(NULL); | ||
71 | } | ||
72 | |||
73 | /* If there is no filename its an empty header, skip it */ | ||
74 | if (xstrlen(tar.formated.name) == 0) { | ||
68 | return(NULL); | 75 | return(NULL); |
69 | } | 76 | } |
70 | 77 | ||
@@ -85,7 +92,32 @@ file_header_t *get_header_tar(FILE *tar_stream) | |||
85 | tar_entry = xcalloc(1, sizeof(file_header_t)); | 92 | tar_entry = xcalloc(1, sizeof(file_header_t)); |
86 | tar_entry->name = xstrdup(tar.formated.name); | 93 | tar_entry->name = xstrdup(tar.formated.name); |
87 | 94 | ||
88 | parse_mode(tar.formated.mode, &tar_entry->mode); | 95 | tar_entry->mode = strtol(tar.formated.mode, NULL, 8); |
96 | #ifdef CONFIG_FEATURE_TAR_OLD_FORMAT | ||
97 | switch (tar.formated.typeflag) { | ||
98 | case 0: | ||
99 | tar_entry->mode |= S_IFREG; | ||
100 | break; | ||
101 | case 1: | ||
102 | error_msg("internal hard link not handled\n"); | ||
103 | break; | ||
104 | case 2: | ||
105 | tar_entry->mode |= S_IFLNK; | ||
106 | break; | ||
107 | case 3: | ||
108 | tar_entry->mode |= S_IFCHR; | ||
109 | break; | ||
110 | case 4: | ||
111 | tar_entry->mode |= S_IFBLK; | ||
112 | break; | ||
113 | case 5: | ||
114 | tar_entry->mode |= S_IFDIR; | ||
115 | break; | ||
116 | case 6: | ||
117 | tar_entry->mode |= S_IFIFO; | ||
118 | break; | ||
119 | } | ||
120 | #endif | ||
89 | tar_entry->uid = strtol(tar.formated.uid, NULL, 8); | 121 | tar_entry->uid = strtol(tar.formated.uid, NULL, 8); |
90 | tar_entry->gid = strtol(tar.formated.gid, NULL, 8); | 122 | tar_entry->gid = strtol(tar.formated.gid, NULL, 8); |
91 | tar_entry->size = strtol(tar.formated.size, NULL, 8); | 123 | tar_entry->size = strtol(tar.formated.size, NULL, 8); |