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;
/* 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);
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);
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);
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) {