blob: 5e631705cff0684ff35ba0d16bf8d19b21abe63e [file] [log] [blame]
Glenn L McGrath87ac7022002-01-02 13:52:26 +00001/* vi: set sw=4 ts=4: */
2/*
3 * Mini unzip implementation for busybox
4 *
Paul Fox0840b762005-07-20 20:26:49 +00005 * Copyright (C) 2004 by Ed Clark
6 *
7 * Loosely based on original busybox unzip applet by Laurence Anderson.
8 * All options and features should work in this version.
Glenn L McGrath87ac7022002-01-02 13:52:26 +00009 *
Bernhard Reutner-Fischer86f5c992006-01-22 22:55:11 +000010 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
Glenn L McGrath87ac7022002-01-02 13:52:26 +000011 */
12
Glenn L McGrathf34b0e92004-06-06 10:22:43 +000013/* For reference see
Paul Fox0840b762005-07-20 20:26:49 +000014 * http://www.pkware.com/company/standards/appnote/
Glenn L McGrathf34b0e92004-06-06 10:22:43 +000015 * http://www.info-zip.org/pub/infozip/doc/appnote-iz-latest.zip
16 */
Glenn L McGrath7ca04f32002-09-25 02:47:48 +000017
Paul Fox0840b762005-07-20 20:26:49 +000018/* TODO
19 * Endian issues
20 * Zip64 + other methods
21 * Improve handling of zip format, ie.
22 * - deferred CRC, comp. & uncomp. lengths (zip header flags bit 3)
23 * - unix file permissions, etc.
24 * - central directory
25 */
Glenn L McGrath7ca04f32002-09-25 02:47:48 +000026
Glenn L McGrath87ac7022002-01-02 13:52:26 +000027#include "busybox.h"
Rob Landleyd921b2e2006-08-03 15:41:12 +000028#include "unarchive.h"
Glenn L McGrath87ac7022002-01-02 13:52:26 +000029
Rob Landley53437472006-07-16 08:14:35 +000030#define ZIP_FILEHEADER_MAGIC SWAP_LE32(0x04034b50)
31#define ZIP_CDS_MAGIC SWAP_LE32(0x02014b50)
32#define ZIP_CDS_END_MAGIC SWAP_LE32(0x06054b50)
33#define ZIP_DD_MAGIC SWAP_LE32(0x08074b50)
Glenn L McGrath7ca04f32002-09-25 02:47:48 +000034
Paul Fox0840b762005-07-20 20:26:49 +000035typedef union {
36 unsigned char raw[26];
37 struct {
38 unsigned short version; /* 0-1 */
39 unsigned short flags; /* 2-3 */
40 unsigned short method; /* 4-5 */
41 unsigned short modtime; /* 6-7 */
42 unsigned short moddate; /* 8-9 */
Tim Rikerc1ef7bd2006-01-25 00:08:53 +000043 unsigned int crc32 ATTRIBUTE_PACKED; /* 10-13 */
44 unsigned int cmpsize ATTRIBUTE_PACKED; /* 14-17 */
Bernhard Reutner-Fischer86f5c992006-01-22 22:55:11 +000045 unsigned int ucmpsize ATTRIBUTE_PACKED; /* 18-21 */
Paul Fox0840b762005-07-20 20:26:49 +000046 unsigned short filename_len; /* 22-23 */
47 unsigned short extra_len; /* 24-25 */
"Robert P. J. Day"eea56182006-07-20 19:02:24 +000048 } formatted ATTRIBUTE_PACKED;
Paul Fox0840b762005-07-20 20:26:49 +000049} zip_header_t;
50
51static void unzip_skip(int fd, off_t skip)
Glenn L McGrath7ca04f32002-09-25 02:47:48 +000052{
Paul Fox0840b762005-07-20 20:26:49 +000053 if (lseek(fd, skip, SEEK_CUR) == (off_t)-1) {
Denis Vlasenko714701c2006-12-22 00:21:07 +000054 if (errno != ESPIPE)
Denis Vlasenko13858992006-10-08 12:49:22 +000055 bb_error_msg_and_die("seek failure");
Denis Vlasenko714701c2006-12-22 00:21:07 +000056 bb_copyfd_exact_size(fd, -1, skip);
Paul Fox0840b762005-07-20 20:26:49 +000057 }
Glenn L McGrath7ca04f32002-09-25 02:47:48 +000058}
59
Paul Fox0840b762005-07-20 20:26:49 +000060static void unzip_create_leading_dirs(char *fn)
61{
62 /* Create all leading directories */
Rob Landleyd921b2e2006-08-03 15:41:12 +000063 char *name = xstrdup(fn);
Paul Fox0840b762005-07-20 20:26:49 +000064 if (bb_make_directory(dirname(name), 0777, FILEUTILS_RECUR)) {
Denis Vlasenko13858992006-10-08 12:49:22 +000065 bb_error_msg_and_die("exiting"); /* bb_make_directory is noisy */
Paul Fox0840b762005-07-20 20:26:49 +000066 }
67 free(name);
68}
69
Paul Fox986ab522006-03-27 23:09:14 +000070static int unzip_extract(zip_header_t *zip_header, int src_fd, int dst_fd)
Paul Fox0840b762005-07-20 20:26:49 +000071{
"Robert P. J. Day"eea56182006-07-20 19:02:24 +000072 if (zip_header->formatted.method == 0) {
Paul Fox0840b762005-07-20 20:26:49 +000073 /* Method 0 - stored (not compressed) */
Denis Vlasenko7039a662006-10-08 17:54:47 +000074 off_t size = zip_header->formatted.ucmpsize;
Denis Vlasenko714701c2006-12-22 00:21:07 +000075 if (size)
76 bb_copyfd_exact_size(src_fd, dst_fd, size);
Paul Fox0840b762005-07-20 20:26:49 +000077 } else {
78 /* Method 8 - inflate */
Denis Vlasenkocd42cb82007-01-05 23:56:53 +000079 inflate_unzip_result res;
80 /* err = */ inflate_unzip(&res, zip_header->formatted.cmpsize, src_fd, dst_fd);
81// we should check for -1 error return
Paul Fox0840b762005-07-20 20:26:49 +000082 /* Validate decompression - crc */
Denis Vlasenkocd42cb82007-01-05 23:56:53 +000083 if (zip_header->formatted.crc32 != (res.crc ^ 0xffffffffL)) {
Denis Vlasenko13858992006-10-08 12:49:22 +000084 bb_error_msg("invalid compressed data--%s error", "crc");
Paul Fox986ab522006-03-27 23:09:14 +000085 return 1;
Paul Fox0840b762005-07-20 20:26:49 +000086 }
87 /* Validate decompression - size */
Denis Vlasenkocd42cb82007-01-05 23:56:53 +000088 if (zip_header->formatted.ucmpsize != res.bytes_out) {
Denis Vlasenko13858992006-10-08 12:49:22 +000089 bb_error_msg("invalid compressed data--%s error", "length");
Paul Fox986ab522006-03-27 23:09:14 +000090 return 1;
Paul Fox0840b762005-07-20 20:26:49 +000091 }
92 }
Paul Fox986ab522006-03-27 23:09:14 +000093 return 0;
Glenn L McGrath7ca04f32002-09-25 02:47:48 +000094}
95
Denis Vlasenko06af2162007-02-03 17:28:39 +000096int unzip_main(int argc, char **argv);
Rob Landleydfba7412006-03-06 20:47:33 +000097int unzip_main(int argc, char **argv)
Glenn L McGrath87ac7022002-01-02 13:52:26 +000098{
Paul Fox0840b762005-07-20 20:26:49 +000099 zip_header_t zip_header;
100 enum {v_silent, v_normal, v_list} verbosity = v_normal;
101 enum {o_prompt, o_never, o_always} overwrite = o_prompt;
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000102 unsigned int total_size = 0;
103 unsigned int total_entries = 0;
Paul Fox0840b762005-07-20 20:26:49 +0000104 int src_fd = -1, dst_fd = -1;
105 char *src_fn = NULL, *dst_fn = NULL;
Mike Frysinger69024552005-07-30 07:30:26 +0000106 llist_t *zaccept = NULL;
107 llist_t *zreject = NULL;
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000108 char *base_dir = NULL;
Paul Fox986ab522006-03-27 23:09:14 +0000109 int failed, i, opt, opt_range = 0, list_header_done = 0;
Paul Fox0840b762005-07-20 20:26:49 +0000110 char key_buf[512];
111 struct stat stat_buf;
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000112
Denis Vlasenkobf0a2012006-12-26 10:42:51 +0000113 while ((opt = getopt(argc, argv, "-d:lnopqx")) != -1) {
Denis Vlasenkoc16bd212006-09-27 19:51:06 +0000114 switch (opt_range) {
Paul Fox0840b762005-07-20 20:26:49 +0000115 case 0: /* Options */
Denis Vlasenkoc16bd212006-09-27 19:51:06 +0000116 switch (opt) {
Paul Fox0840b762005-07-20 20:26:49 +0000117 case 'l': /* List */
118 verbosity = v_list;
119 break;
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000120
Paul Fox0840b762005-07-20 20:26:49 +0000121 case 'n': /* Never overwrite existing files */
122 overwrite = o_never;
Glenn L McGrath87ac7022002-01-02 13:52:26 +0000123 break;
Paul Fox0840b762005-07-20 20:26:49 +0000124
125 case 'o': /* Always overwrite existing files */
126 overwrite = o_always;
Glenn L McGrath87ac7022002-01-02 13:52:26 +0000127 break;
Paul Fox0840b762005-07-20 20:26:49 +0000128
129 case 'p': /* Extract files to stdout and fall through to set verbosity */
130 dst_fd = STDOUT_FILENO;
131
132 case 'q': /* Be quiet */
133 verbosity = (verbosity == v_normal) ? v_silent : verbosity;
Glenn L McGrath87ac7022002-01-02 13:52:26 +0000134 break;
Paul Fox0840b762005-07-20 20:26:49 +0000135
136 case 1 : /* The zip file */
Rob Landleyd921b2e2006-08-03 15:41:12 +0000137 src_fn = xstrndup(optarg, strlen(optarg)+4);
Paul Fox0840b762005-07-20 20:26:49 +0000138 opt_range++;
Glenn L McGrath87ac7022002-01-02 13:52:26 +0000139 break;
Paul Fox0840b762005-07-20 20:26:49 +0000140
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000141 default:
Manuel Novoa III cad53642003-03-19 09:13:01 +0000142 bb_show_usage();
Paul Fox0840b762005-07-20 20:26:49 +0000143
144 }
145 break;
146
147 case 1: /* Include files */
148 if (opt == 1) {
Rob Landley8bb50782006-05-26 23:44:51 +0000149 llist_add_to(&zaccept, optarg);
Paul Fox0840b762005-07-20 20:26:49 +0000150
151 } else if (opt == 'd') {
152 base_dir = optarg;
153 opt_range += 2;
154
155 } else if (opt == 'x') {
156 opt_range++;
157
158 } else {
159 bb_show_usage();
160 }
161 break;
162
163 case 2 : /* Exclude files */
164 if (opt == 1) {
Rob Landley8bb50782006-05-26 23:44:51 +0000165 llist_add_to(&zreject, optarg);
Paul Fox0840b762005-07-20 20:26:49 +0000166
167 } else if (opt == 'd') { /* Extract to base directory */
168 base_dir = optarg;
169 opt_range++;
170
171 } else {
172 bb_show_usage();
173 }
174 break;
175
176 default:
177 bb_show_usage();
Glenn L McGrath87ac7022002-01-02 13:52:26 +0000178 }
179 }
180
Paul Fox0840b762005-07-20 20:26:49 +0000181 if (src_fn == NULL) {
Manuel Novoa III cad53642003-03-19 09:13:01 +0000182 bb_show_usage();
Glenn L McGrath87ac7022002-01-02 13:52:26 +0000183 }
184
Paul Fox0840b762005-07-20 20:26:49 +0000185 /* Open input file */
Denis Vlasenko9f739442006-12-16 23:49:13 +0000186 if (LONE_DASH(src_fn)) {
Paul Fox0840b762005-07-20 20:26:49 +0000187 src_fd = STDIN_FILENO;
188 /* Cannot use prompt mode since zip data is arriving on STDIN */
189 overwrite = (overwrite == o_prompt) ? o_never : overwrite;
Glenn L McGrath237ae422002-11-03 14:05:15 +0000190 } else {
Rob Landley0a7c8ef2006-02-22 17:01:00 +0000191 static const char *const extn[] = {"", ".zip", ".ZIP"};
Paul Fox0840b762005-07-20 20:26:49 +0000192 int orig_src_fn_len = strlen(src_fn);
Denis Vlasenkobf0a2012006-12-26 10:42:51 +0000193 for (i = 0; (i < 3) && (src_fd == -1); i++) {
Paul Fox0840b762005-07-20 20:26:49 +0000194 strcpy(src_fn + orig_src_fn_len, extn[i]);
195 src_fd = open(src_fn, O_RDONLY);
196 }
197 if (src_fd == -1) {
198 src_fn[orig_src_fn_len] = 0;
Denis Vlasenko7039a662006-10-08 17:54:47 +0000199 bb_error_msg_and_die("cannot open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn);
Paul Fox0840b762005-07-20 20:26:49 +0000200 }
Glenn L McGrath237ae422002-11-03 14:05:15 +0000201 }
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000202
Paul Fox0840b762005-07-20 20:26:49 +0000203 /* Change dir if necessary */
Bernhard Reutner-Fischerd9cf7ac2006-04-12 18:39:58 +0000204 if (base_dir)
Rob Landleyd921b2e2006-08-03 15:41:12 +0000205 xchdir(base_dir);
Glenn L McGrath87ac7022002-01-02 13:52:26 +0000206
Paul Fox0840b762005-07-20 20:26:49 +0000207 if (verbosity != v_silent)
208 printf("Archive: %s\n", src_fn);
Glenn L McGrath87ac7022002-01-02 13:52:26 +0000209
Paul Fox986ab522006-03-27 23:09:14 +0000210 failed = 0;
211
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000212 while (1) {
213 unsigned int magic;
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000214
Paul Fox0840b762005-07-20 20:26:49 +0000215 /* Check magic number */
Rob Landley53437472006-07-16 08:14:35 +0000216 xread(src_fd, &magic, 4);
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000217 if (magic == ZIP_CDS_MAGIC) {
218 break;
Paul Fox0840b762005-07-20 20:26:49 +0000219 } else if (magic != ZIP_FILEHEADER_MAGIC) {
Denis Vlasenkod3d004d2006-10-27 09:02:31 +0000220 bb_error_msg_and_die("invalid zip magic %08X", magic);
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000221 }
222
223 /* Read the file header */
Rob Landley53437472006-07-16 08:14:35 +0000224 xread(src_fd, zip_header.raw, 26);
"Robert P. J. Day"eea56182006-07-20 19:02:24 +0000225 zip_header.formatted.version = SWAP_LE32(zip_header.formatted.version);
226 zip_header.formatted.flags = SWAP_LE32(zip_header.formatted.flags);
227 zip_header.formatted.method = SWAP_LE32(zip_header.formatted.method);
228 zip_header.formatted.modtime = SWAP_LE32(zip_header.formatted.modtime);
229 zip_header.formatted.moddate = SWAP_LE32(zip_header.formatted.moddate);
230 zip_header.formatted.crc32 = SWAP_LE32(zip_header.formatted.crc32);
231 zip_header.formatted.cmpsize = SWAP_LE32(zip_header.formatted.cmpsize);
232 zip_header.formatted.ucmpsize = SWAP_LE32(zip_header.formatted.ucmpsize);
233 zip_header.formatted.filename_len = SWAP_LE32(zip_header.formatted.filename_len);
234 zip_header.formatted.extra_len = SWAP_LE32(zip_header.formatted.extra_len);
235 if ((zip_header.formatted.method != 0) && (zip_header.formatted.method != 8)) {
Denis Vlasenkod3d004d2006-10-27 09:02:31 +0000236 bb_error_msg_and_die("unsupported compression method %d", zip_header.formatted.method);
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000237 }
238
239 /* Read filename */
Paul Fox0840b762005-07-20 20:26:49 +0000240 free(dst_fn);
"Robert P. J. Day"eea56182006-07-20 19:02:24 +0000241 dst_fn = xzalloc(zip_header.formatted.filename_len + 1);
242 xread(src_fd, dst_fn, zip_header.formatted.filename_len);
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000243
Paul Fox0840b762005-07-20 20:26:49 +0000244 /* Skip extra header bytes */
"Robert P. J. Day"eea56182006-07-20 19:02:24 +0000245 unzip_skip(src_fd, zip_header.formatted.extra_len);
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000246
Paul Fox0840b762005-07-20 20:26:49 +0000247 if ((verbosity == v_list) && !list_header_done){
Denis Vlasenko714701c2006-12-22 00:21:07 +0000248 puts(" Length Date Time Name\n"
249 " -------- ---- ---- ----");
Paul Fox0840b762005-07-20 20:26:49 +0000250 list_header_done = 1;
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000251 }
252
Paul Fox0840b762005-07-20 20:26:49 +0000253 /* Filter zip entries */
Mike Frysinger69024552005-07-30 07:30:26 +0000254 if (find_list_entry(zreject, dst_fn) ||
255 (zaccept && !find_list_entry(zaccept, dst_fn))) { /* Skip entry */
Paul Fox0840b762005-07-20 20:26:49 +0000256 i = 'n';
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000257
Paul Fox0840b762005-07-20 20:26:49 +0000258 } else { /* Extract entry */
"Robert P. J. Day"eea56182006-07-20 19:02:24 +0000259 total_size += zip_header.formatted.ucmpsize;
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000260
Paul Fox0840b762005-07-20 20:26:49 +0000261 if (verbosity == v_list) { /* List entry */
"Robert P. J. Day"eea56182006-07-20 19:02:24 +0000262 unsigned int dostime = zip_header.formatted.modtime | (zip_header.formatted.moddate << 16);
Paul Fox0840b762005-07-20 20:26:49 +0000263 printf("%9u %02u-%02u-%02u %02u:%02u %s\n",
"Robert P. J. Day"eea56182006-07-20 19:02:24 +0000264 zip_header.formatted.ucmpsize,
Paul Fox0840b762005-07-20 20:26:49 +0000265 (dostime & 0x01e00000) >> 21,
266 (dostime & 0x001f0000) >> 16,
267 (((dostime & 0xfe000000) >> 25) + 1980) % 100,
268 (dostime & 0x0000f800) >> 11,
269 (dostime & 0x000007e0) >> 5,
270 dst_fn);
271 total_entries++;
272 i = 'n';
Paul Fox0840b762005-07-20 20:26:49 +0000273 } else if (dst_fd == STDOUT_FILENO) { /* Extracting to STDOUT */
274 i = -1;
Paul Fox0840b762005-07-20 20:26:49 +0000275 } else if (last_char_is(dst_fn, '/')) { /* Extract directory */
276 if (stat(dst_fn, &stat_buf) == -1) {
277 if (errno != ENOENT) {
Denis Vlasenkod3d004d2006-10-27 09:02:31 +0000278 bb_perror_msg_and_die("cannot stat '%s'",dst_fn);
Paul Fox0840b762005-07-20 20:26:49 +0000279 }
280 if (verbosity == v_normal) {
281 printf(" creating: %s\n", dst_fn);
282 }
283 unzip_create_leading_dirs(dst_fn);
284 if (bb_make_directory(dst_fn, 0777, 0)) {
Denis Vlasenkod3d004d2006-10-27 09:02:31 +0000285 bb_error_msg_and_die("exiting");
Paul Fox0840b762005-07-20 20:26:49 +0000286 }
287 } else {
288 if (!S_ISDIR(stat_buf.st_mode)) {
289 bb_error_msg_and_die("'%s' exists but is not directory", dst_fn);
290 }
291 }
292 i = 'n';
293
294 } else { /* Extract file */
Denis Vlasenko714701c2006-12-22 00:21:07 +0000295 _check_file:
Paul Fox0840b762005-07-20 20:26:49 +0000296 if (stat(dst_fn, &stat_buf) == -1) { /* File does not exist */
297 if (errno != ENOENT) {
Denis Vlasenkod3d004d2006-10-27 09:02:31 +0000298 bb_perror_msg_and_die("cannot stat '%s'",dst_fn);
Paul Fox0840b762005-07-20 20:26:49 +0000299 }
300 i = 'y';
Paul Fox0840b762005-07-20 20:26:49 +0000301 } else { /* File already exists */
302 if (overwrite == o_never) {
303 i = 'n';
Paul Fox0840b762005-07-20 20:26:49 +0000304 } else if (S_ISREG(stat_buf.st_mode)) { /* File is regular file */
305 if (overwrite == o_always) {
306 i = 'y';
307 } else {
308 printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn);
309 if (!fgets(key_buf, 512, stdin)) {
Denis Vlasenkod3d004d2006-10-27 09:02:31 +0000310 bb_perror_msg_and_die("cannot read input");
Paul Fox0840b762005-07-20 20:26:49 +0000311 }
312 i = key_buf[0];
313 }
Paul Fox0840b762005-07-20 20:26:49 +0000314 } else { /* File is not regular file */
315 bb_error_msg_and_die("'%s' exists but is not regular file",dst_fn);
316 }
317 }
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000318 }
319 }
320
Paul Fox0840b762005-07-20 20:26:49 +0000321 switch (i) {
322 case 'A':
323 overwrite = o_always;
324 case 'y': /* Open file and fall into unzip */
325 unzip_create_leading_dirs(dst_fn);
Bernhard Reutner-Fischer64d7e932006-09-11 16:01:40 +0000326 dst_fd = xopen(dst_fn, O_WRONLY | O_CREAT | O_TRUNC);
Paul Fox0840b762005-07-20 20:26:49 +0000327 case -1: /* Unzip */
328 if (verbosity == v_normal) {
329 printf(" inflating: %s\n", dst_fn);
330 }
Paul Fox986ab522006-03-27 23:09:14 +0000331 if (unzip_extract(&zip_header, src_fd, dst_fd)) {
Denis Vlasenko714701c2006-12-22 00:21:07 +0000332 failed = 1;
Paul Fox986ab522006-03-27 23:09:14 +0000333 }
Paul Fox0840b762005-07-20 20:26:49 +0000334 if (dst_fd != STDOUT_FILENO) {
335 /* closing STDOUT is potentially bad for future business */
336 close(dst_fd);
337 }
338 break;
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000339
Paul Fox0840b762005-07-20 20:26:49 +0000340 case 'N':
341 overwrite = o_never;
342 case 'n':
343 /* Skip entry data */
"Robert P. J. Day"eea56182006-07-20 19:02:24 +0000344 unzip_skip(src_fd, zip_header.formatted.cmpsize);
Paul Fox0840b762005-07-20 20:26:49 +0000345 break;
346
347 case 'r':
348 /* Prompt for new name */
349 printf("new name: ");
350 if (!fgets(key_buf, 512, stdin)) {
Denis Vlasenkod3d004d2006-10-27 09:02:31 +0000351 bb_perror_msg_and_die("cannot read input");
Paul Fox0840b762005-07-20 20:26:49 +0000352 }
353 free(dst_fn);
Rob Landleyd921b2e2006-08-03 15:41:12 +0000354 dst_fn = xstrdup(key_buf);
Paul Fox0840b762005-07-20 20:26:49 +0000355 chomp(dst_fn);
356 goto _check_file;
357
358 default:
Rob Landleye7c43b62006-03-01 16:39:45 +0000359 printf("error: invalid response [%c]\n",(char)i);
Paul Fox0840b762005-07-20 20:26:49 +0000360 goto _check_file;
361 }
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000362
363 /* Data descriptor section */
"Robert P. J. Day"eea56182006-07-20 19:02:24 +0000364 if (zip_header.formatted.flags & 4) {
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000365 /* skip over duplicate crc, compressed size and uncompressed size */
Paul Fox0840b762005-07-20 20:26:49 +0000366 unzip_skip(src_fd, 12);
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000367 }
368 }
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000369
Paul Fox0840b762005-07-20 20:26:49 +0000370 if (verbosity == v_list) {
Rob Landleye7c43b62006-03-01 16:39:45 +0000371 printf(" -------- -------\n"
372 "%9d %d files\n", total_size, total_entries);
Glenn L McGrath7ca04f32002-09-25 02:47:48 +0000373 }
374
Paul Fox986ab522006-03-27 23:09:14 +0000375 return failed;
Glenn L McGrath87ac7022002-01-02 13:52:26 +0000376}