summaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
authorDenis Vlasenko2008-07-26 17:32:41 +0000
committerDenis Vlasenko2008-07-26 17:32:41 +0000
commit48a9971bd41a6ad7fc2ee52dcc885b25012b5561 (patch)
tree91a16ebe8a7d177d0c4cfdbfd3dff123805bf6cd /archival
parentc2dcb7cf63993a80208db653d1f9d39eab5a4567 (diff)
downloadbusybox-48a9971bd41a6ad7fc2ee52dcc885b25012b5561.zip
busybox-48a9971bd41a6ad7fc2ee52dcc885b25012b5561.tar.gz
unzip: move check for unsupported zip features to better place
Diffstat (limited to 'archival')
-rw-r--r--archival/unzip.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/archival/unzip.c b/archival/unzip.c
index 36490cb..1c9bc24 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -99,12 +99,6 @@ static void unzip_create_leading_dirs(const char *fn)
static void unzip_extract(zip_header_t *zip_header, int src_fd, int dst_fd)
{
- if (zip_header->formatted.flags & (0x0008|0x0001)) {
- /* 0x0001 - encrypted */
- /* 0x0008 - streaming. [u]cmpsize can be reliably gotten
- * only from Central Directory. See unzip_doc.txt */
- bb_error_msg_and_die("zip flags 8 and 1 are not supported");
- }
if (zip_header->formatted.method == 0) {
/* Method 0 - stored (not compressed) */
off_t size = zip_header->formatted.ucmpsize;
@@ -264,10 +258,11 @@ int unzip_main(int argc, char **argv)
/* Check magic number */
xread(src_fd, &magic, 4);
+ /* Central directory? It's at the end, so exit */
if (magic == ZIP_CDS_MAGIC)
break;
if (magic != ZIP_FILEHEADER_MAGIC)
- bb_error_msg_and_die("invalid zip magic %08X", magic);
+ bb_error_msg_and_die("invalid zip magic %08X", (int)magic);
/* Read the file header */
xread(src_fd, zip_header.raw, ZIP_HEADER_LEN);
@@ -275,6 +270,12 @@ int unzip_main(int argc, char **argv)
if ((zip_header.formatted.method != 0) && (zip_header.formatted.method != 8)) {
bb_error_msg_and_die("unsupported method %d", zip_header.formatted.method);
}
+ if (zip_header.formatted.flags & (0x0008|0x0001)) {
+ /* 0x0001 - encrypted */
+ /* 0x0008 - streaming. [u]cmpsize can be reliably gotten
+ * only from Central Directory. See unzip_doc.txt */
+ bb_error_msg_and_die("zip flags 8 and 1 are not supported");
+ }
/* Read filename */
free(dst_fn);
@@ -331,7 +332,7 @@ int unzip_main(int argc, char **argv)
i = 'n';
} else { /* Extract file */
- _check_file:
+ check_file:
if (stat(dst_fn, &stat_buf) == -1) { /* File does not exist */
if (errno != ENOENT) {
bb_perror_msg_and_die("cannot stat '%s'", dst_fn);
@@ -390,18 +391,19 @@ int unzip_main(int argc, char **argv)
free(dst_fn);
dst_fn = xstrdup(key_buf);
chomp(dst_fn);
- goto _check_file;
+ goto check_file;
default:
printf("error: invalid response [%c]\n",(char)i);
- goto _check_file;
+ goto check_file;
}
- /* Data descriptor section */
- if (zip_header.formatted.flags & 4) {
- /* skip over duplicate crc, compressed size and uncompressed size */
- unzip_skip(src_fd, 12);
- }
+// Looks like bug (data descriptor cannot be identified this way)
+// /* Data descriptor section */
+// if (zip_header.formatted.flags & 4) {
+// /* skip over duplicate crc, compressed size and uncompressed size */
+// unzip_skip(src_fd, 12);
+// }
}
if (listing && verbose) {