summaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
authorMatt Kraai2001-04-18 14:49:55 +0000
committerMatt Kraai2001-04-18 14:49:55 +0000
commitb181056e06974e72f210189bf758d76dc2ecdde6 (patch)
tree4a11033060a23ab60a11045331b21e3d144326eb /archival
parentbcfeb2ac44a468f7f7487883f418e026f8e76348 (diff)
downloadbusybox-b181056e06974e72f210189bf758d76dc2ecdde6.zip
busybox-b181056e06974e72f210189bf758d76dc2ecdde6.tar.gz
Eliminated seeks so that we work correctly on pipes, and removed reliance on
undefined evaluation ordering. Thanks to Anthony Towns for explanation and solution.
Diffstat (limited to 'archival')
-rw-r--r--archival/libunarchive/decompress_unzip.c11
-rw-r--r--archival/libunarchive/unzip.c11
2 files changed, 18 insertions, 4 deletions
diff --git a/archival/libunarchive/decompress_unzip.c b/archival/libunarchive/decompress_unzip.c
index b843ec8..9568c28 100644
--- a/archival/libunarchive/decompress_unzip.c
+++ b/archival/libunarchive/decompress_unzip.c
@@ -904,6 +904,7 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
int method;
typedef void (*sig_type) (int);
int exit_code=0; /* program exit code */
+ int i;
in_file = l_in_file;
out_file = l_out_file;
@@ -949,10 +950,16 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
flags = (unsigned char) fgetc(in_file);
/* Ignore time stamp(4), extra flags(1), OS type(1) */
- fseek(in_file, 6, SEEK_CUR);
+ for (i = 0; i < 6; i++)
+ fgetc(in_file);
if ((flags & extra_field) != 0) {
- fseek(in_file, (size_t) fgetc(in_file) + ((size_t)fgetc(in_file) << 8), SEEK_CUR);
+ size_t extra;
+ extra = fgetc(in_file);
+ extra += fgetc(in_file) << 8;
+
+ for (i = 0; i < extra; i++)
+ fgetc(in_file);
}
/* Discard original name if any */
diff --git a/archival/libunarchive/unzip.c b/archival/libunarchive/unzip.c
index b843ec8..9568c28 100644
--- a/archival/libunarchive/unzip.c
+++ b/archival/libunarchive/unzip.c
@@ -904,6 +904,7 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
int method;
typedef void (*sig_type) (int);
int exit_code=0; /* program exit code */
+ int i;
in_file = l_in_file;
out_file = l_out_file;
@@ -949,10 +950,16 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
flags = (unsigned char) fgetc(in_file);
/* Ignore time stamp(4), extra flags(1), OS type(1) */
- fseek(in_file, 6, SEEK_CUR);
+ for (i = 0; i < 6; i++)
+ fgetc(in_file);
if ((flags & extra_field) != 0) {
- fseek(in_file, (size_t) fgetc(in_file) + ((size_t)fgetc(in_file) << 8), SEEK_CUR);
+ size_t extra;
+ extra = fgetc(in_file);
+ extra += fgetc(in_file) << 8;
+
+ for (i = 0; i < extra; i++)
+ fgetc(in_file);
}
/* Discard original name if any */