aboutsummaryrefslogtreecommitdiff
path: root/archival/libunarchive
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2003-01-28 01:45:48 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2003-01-28 01:45:48 +0000
commit21110a0aa2bda7346bdd916bbc027dfa38ee7c12 (patch)
treee2ecea1661a39605675307f029bbacc68faa97e9 /archival/libunarchive
parenta99534354a538573770d2b9835856fcfc017dab1 (diff)
downloadbusybox-w32-21110a0aa2bda7346bdd916bbc027dfa38ee7c12.tar.gz
busybox-w32-21110a0aa2bda7346bdd916bbc027dfa38ee7c12.tar.bz2
busybox-w32-21110a0aa2bda7346bdd916bbc027dfa38ee7c12.zip
Fix long standing bug with old gnu tar files, add a check so tar will
complain "unknown file type" if it tries to extract an oldgnu tar file and TAR_FEATURE_OLDGNU_COMPATABILITY sint defined. Print a warning if unisupported gnu extensions are encountered.
Diffstat (limited to 'archival/libunarchive')
-rw-r--r--archival/libunarchive/data_extract_all.c2
-rw-r--r--archival/libunarchive/get_header_tar.c31
2 files changed, 21 insertions, 12 deletions
diff --git a/archival/libunarchive/data_extract_all.c b/archival/libunarchive/data_extract_all.c
index 9c4510e6b..1eb8bb388 100644
--- a/archival/libunarchive/data_extract_all.c
+++ b/archival/libunarchive/data_extract_all.c
@@ -84,6 +84,8 @@ extern void data_extract_all(archive_handle_t *archive_handle)
84 perror_msg("Cannot create node %s", file_header->name); 84 perror_msg("Cannot create node %s", file_header->name);
85 } 85 }
86 break; 86 break;
87 default:
88 error_msg_and_die("Unrecognised file type");
87 } 89 }
88 90
89 chmod(file_header->name, file_header->mode); 91 chmod(file_header->name, file_header->mode);
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c
index 5fed7c1bf..2cb141ede 100644
--- a/archival/libunarchive/get_header_tar.c
+++ b/archival/libunarchive/get_header_tar.c
@@ -20,7 +20,7 @@
20#include "unarchive.h" 20#include "unarchive.h"
21#include "libbb.h" 21#include "libbb.h"
22 22
23#ifdef CONFIG_FEATURE_GNUTAR_LONG_FILENAME 23#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
24static char *longname = NULL; 24static char *longname = NULL;
25static char *linkname = NULL; 25static char *linkname = NULL;
26#endif 26#endif
@@ -72,7 +72,7 @@ extern char get_header_tar(archive_handle_t *archive_handle)
72 * 0's are for the old tar format 72 * 0's are for the old tar format
73 */ 73 */
74 if (strncmp(tar.formated.magic, "ustar", 5) != 0) { 74 if (strncmp(tar.formated.magic, "ustar", 5) != 0) {
75#ifdef CONFIG_FEATURE_TAR_OLD_FORMAT 75#ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY
76 if (strncmp(tar.formated.magic, "\0\0\0\0\0", 5) != 0) 76 if (strncmp(tar.formated.magic, "\0\0\0\0\0", 5) != 0)
77#endif 77#endif
78 error_msg_and_die("Invalid tar magic"); 78 error_msg_and_die("Invalid tar magic");
@@ -90,7 +90,7 @@ extern char get_header_tar(archive_handle_t *archive_handle)
90 return(EXIT_FAILURE); 90 return(EXIT_FAILURE);
91 } 91 }
92 92
93#ifdef CONFIG_FEATURE_GNUTAR_LONG_FILENAME 93#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
94 if (longname) { 94 if (longname) {
95 file_header->name = longname; 95 file_header->name = longname;
96 longname = NULL; 96 longname = NULL;
@@ -120,33 +120,34 @@ extern char get_header_tar(archive_handle_t *archive_handle)
120 file_header->device = (dev_t) ((strtol(tar.formated.devmajor, NULL, 8) << 8) + 120 file_header->device = (dev_t) ((strtol(tar.formated.devmajor, NULL, 8) << 8) +
121 strtol(tar.formated.devminor, NULL, 8)); 121 strtol(tar.formated.devminor, NULL, 8));
122 122
123#if defined CONFIG_FEATURE_TAR_OLD_FORMAT || defined CONFIG_FEATURE_GNUTAR_LONG_FILENAME 123#if defined CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY || defined CONFIG_FEATURE_TAR_GNU_EXTENSIONS
124 /* Fix mode, used by the old format */ 124 /* Fix mode, used by the old format */
125 switch (tar.formated.typeflag) { 125 switch (tar.formated.typeflag) {
126# ifdef CONFIG_FEATURE_TAR_OLD_FORMAT 126# ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY
127 case 0: 127 case 0:
128 case '0':
128 file_header->mode |= S_IFREG; 129 file_header->mode |= S_IFREG;
129 break; 130 break;
130 case 1: 131 case '1':
131 error_msg("Internal hard link not supported"); 132 error_msg("Internal hard link not supported");
132 break; 133 break;
133 case 2: 134 case '2':
134 file_header->mode |= S_IFLNK; 135 file_header->mode |= S_IFLNK;
135 break; 136 break;
136 case 3: 137 case '3':
137 file_header->mode |= S_IFCHR; 138 file_header->mode |= S_IFCHR;
138 break; 139 break;
139 case 4: 140 case '4':
140 file_header->mode |= S_IFBLK; 141 file_header->mode |= S_IFBLK;
141 break; 142 break;
142 case 5: 143 case '5':
143 file_header->mode |= S_IFDIR; 144 file_header->mode |= S_IFDIR;
144 break; 145 break;
145 case 6: 146 case '6':
146 file_header->mode |= S_IFIFO; 147 file_header->mode |= S_IFIFO;
147 break; 148 break;
148# endif 149# endif
149# ifdef CONFIG_FEATURE_GNUTAR_LONG_FILENAME 150# ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
150 case 'L': { 151 case 'L': {
151 longname = xmalloc(file_header->size + 1); 152 longname = xmalloc(file_header->size + 1);
152 archive_xread_all(archive_handle, longname, file_header->size); 153 archive_xread_all(archive_handle, longname, file_header->size);
@@ -164,6 +165,12 @@ extern char get_header_tar(archive_handle_t *archive_handle)
164 file_header->name = linkname; 165 file_header->name = linkname;
165 return(get_header_tar(archive_handle)); 166 return(get_header_tar(archive_handle));
166 } 167 }
168 case 'D':
169 case 'M':
170 case 'N':
171 case 'S':
172 case 'V':
173 error_msg("Ignoring GNU extension type %c", tar.formated.typeflag);
167# endif 174# endif
168 } 175 }
169#endif 176#endif