aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2004-02-17 11:55:06 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2004-02-17 11:55:06 +0000
commit6aa52234e8c0aa7da84220718e3289a308b3d702 (patch)
tree5dd2244c0f1b888d642087ed620c6297bdcd5aa3
parent7b565a0c8ae3c4b1fc982bd8a08bd303e87fd1a9 (diff)
downloadbusybox-w32-6aa52234e8c0aa7da84220718e3289a308b3d702.tar.gz
busybox-w32-6aa52234e8c0aa7da84220718e3289a308b3d702.tar.bz2
busybox-w32-6aa52234e8c0aa7da84220718e3289a308b3d702.zip
Dont strip trailing '/' until _after_ i test to set if its there !
-rw-r--r--archival/libunarchive/get_header_tar.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c
index 561de1c03..4e31b8521 100644
--- a/archival/libunarchive/get_header_tar.c
+++ b/archival/libunarchive/get_header_tar.c
@@ -12,6 +12,10 @@
12 * You should have received a copy of the GNU General Public License 12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software 13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 *
16 * FIXME: Better checking required in oldcompatability mode,
17 * the file db.1.85.tar.gz from sleepycat.com has trailing garbage
18 * GNU tar can handle it, busybox tar reports invalid tar header.
15 */ 19 */
16 20
17#include <stdio.h> 21#include <stdio.h>
@@ -106,14 +110,6 @@ extern char get_header_tar(archive_handle_t *archive_handle)
106 file_header->name = concat_path_file(tar.formated.prefix, tar.formated.name); 110 file_header->name = concat_path_file(tar.formated.prefix, tar.formated.name);
107 } 111 }
108 112
109 { /* Strip trailing '/' in directories */
110 char *tmp = last_char_is(file_header->name, '/');
111 if (tmp) {
112 *tmp = '\0';
113 }
114 }
115
116
117 file_header->mode = strtol(tar.formated.mode, NULL, 8); 113 file_header->mode = strtol(tar.formated.mode, NULL, 8);
118 file_header->uid = strtol(tar.formated.uid, NULL, 8); 114 file_header->uid = strtol(tar.formated.uid, NULL, 8);
119 file_header->gid = strtol(tar.formated.gid, NULL, 8); 115 file_header->gid = strtol(tar.formated.gid, NULL, 8);
@@ -126,12 +122,14 @@ extern char get_header_tar(archive_handle_t *archive_handle)
126 122
127 /* Fix mode, used by the old format */ 123 /* Fix mode, used by the old format */
128 switch (tar.formated.typeflag) { 124 switch (tar.formated.typeflag) {
129# ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY 125#ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY
130 case 0: 126 case 0:
131 case '0': 127 case '0':
132 if (last_char_is(file_header->name, '/')) { 128 if (last_char_is(file_header->name, '/')) {
129 printf("directory\n");
133 file_header->mode |= S_IFDIR; 130 file_header->mode |= S_IFDIR;
134 } else { 131 } else {
132 printf("regular file\n");
135 file_header->mode |= S_IFREG; 133 file_header->mode |= S_IFREG;
136 } 134 }
137 break; 135 break;
@@ -150,12 +148,12 @@ extern char get_header_tar(archive_handle_t *archive_handle)
150 case '6': 148 case '6':
151 file_header->mode |= S_IFIFO; 149 file_header->mode |= S_IFIFO;
152 break; 150 break;
153# endif 151#endif
154 /* hard links are detected as regular files with 0 size and a link name */ 152 /* hard links are detected as regular files with 0 size and a link name */
155 case '1': 153 case '1':
156 file_header->mode &= (S_IFREG | 07777); 154 file_header->mode &= (S_IFREG | 07777);
157 break; 155 break;
158# ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS 156#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
159 case 'L': { 157 case 'L': {
160 longname = xmalloc(file_header->size + 1); 158 longname = xmalloc(file_header->size + 1);
161 archive_xread_all(archive_handle, longname, file_header->size); 159 archive_xread_all(archive_handle, longname, file_header->size);
@@ -179,7 +177,14 @@ extern char get_header_tar(archive_handle_t *archive_handle)
179 case 'S': 177 case 'S':
180 case 'V': 178 case 'V':
181 bb_error_msg("Ignoring GNU extension type %c", tar.formated.typeflag); 179 bb_error_msg("Ignoring GNU extension type %c", tar.formated.typeflag);
182# endif 180#endif
181 }
182 { /* Strip trailing '/' in directories */
183 /* Must be done after mode is set as '/' is used to check if its a directory */
184 char *tmp = last_char_is(file_header->name, '/');
185 if (tmp) {
186 *tmp = '\0';
187 }
183 } 188 }
184 189
185 if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) { 190 if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {