summaryrefslogtreecommitdiff
path: root/archival/unzip.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-12-22 00:21:07 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-12-22 00:21:07 +0000
commit714701c890b5f03253c5ecdb7367c4258ce78715 (patch)
tree7ddaf73cf2deda0f357b21802dab4d42798dd778 /archival/unzip.c
parent0a8a7741795880201bcf78231d1eab0e2538bb0b (diff)
downloadbusybox-714701c890b5f03253c5ecdb7367c4258ce78715.tar.gz
tar et al: die if bb_copyfd_size copies less than asked for.
(we have bb_copyfd_exact_size now for that kind of usage)
Diffstat (limited to 'archival/unzip.c')
-rw-r--r--archival/unzip.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/archival/unzip.c b/archival/unzip.c
index f553eefa2..1c03a4c47 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -54,9 +54,9 @@ typedef union {
static void unzip_skip(int fd, off_t skip)
{
if (lseek(fd, skip, SEEK_CUR) == (off_t)-1) {
- if ((errno != ESPIPE) || (bb_copyfd_size(fd, -1, skip) != skip)) {
+ if (errno != ESPIPE)
bb_error_msg_and_die("seek failure");
- }
+ bb_copyfd_exact_size(fd, -1, skip);
}
}
@@ -75,10 +75,8 @@ static int unzip_extract(zip_header_t *zip_header, int src_fd, int dst_fd)
if (zip_header->formatted.method == 0) {
/* Method 0 - stored (not compressed) */
off_t size = zip_header->formatted.ucmpsize;
- if (size && (bb_copyfd_size(src_fd, dst_fd, size) != size)) {
- bb_error_msg_and_die("cannot complete extraction");
- }
-
+ if (size)
+ bb_copyfd_exact_size(src_fd, dst_fd, size);
} else {
/* Method 8 - inflate */
inflate_init(zip_header->formatted.cmpsize);
@@ -249,8 +247,8 @@ int unzip_main(int argc, char **argv)
unzip_skip(src_fd, zip_header.formatted.extra_len);
if ((verbosity == v_list) && !list_header_done){
- printf(" Length Date Time Name\n"
- " -------- ---- ---- ----\n");
+ puts(" Length Date Time Name\n"
+ " -------- ---- ---- ----");
list_header_done = 1;
}
@@ -274,10 +272,8 @@ int unzip_main(int argc, char **argv)
dst_fn);
total_entries++;
i = 'n';
-
} else if (dst_fd == STDOUT_FILENO) { /* Extracting to STDOUT */
i = -1;
-
} else if (last_char_is(dst_fn, '/')) { /* Extract directory */
if (stat(dst_fn, &stat_buf) == -1) {
if (errno != ENOENT) {
@@ -298,17 +294,15 @@ 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);
}
i = 'y';
-
} else { /* File already exists */
if (overwrite == o_never) {
i = 'n';
-
} else if (S_ISREG(stat_buf.st_mode)) { /* File is regular file */
if (overwrite == o_always) {
i = 'y';
@@ -319,7 +313,6 @@ int unzip_main(int argc, char **argv)
}
i = key_buf[0];
}
-
} else { /* File is not regular file */
bb_error_msg_and_die("'%s' exists but is not regular file",dst_fn);
}
@@ -338,7 +331,7 @@ int unzip_main(int argc, char **argv)
printf(" inflating: %s\n", dst_fn);
}
if (unzip_extract(&zip_header, src_fd, dst_fd)) {
- failed = 1;
+ failed = 1;
}
if (dst_fd != STDOUT_FILENO) {
/* closing STDOUT is potentially bad for future business */