summaryrefslogtreecommitdiff
path: root/unzip.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>1999-10-06 05:00:00 +0000
committerPaul Eggert <eggert@cs.ucla.edu>1999-10-06 05:00:00 +0000
commitd9a513aab586c69e2b87b3ed1fa12b22c5632e4f (patch)
tree12a1c979ce132de4766be5fff03ca950d2c64c10 /unzip.c
parente2027e9e7b8668e4c5c21bbf61407fe1d9d371df (diff)
downloadgzip-d9a513aab586c69e2b87b3ed1fa12b22c5632e4f.tar.gz
gzip 1.3.5
Diffstat (limited to 'unzip.c')
-rw-r--r--unzip.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/unzip.c b/unzip.c
index cd3d50e..db3e3ac 100644
--- a/unzip.c
+++ b/unzip.c
@@ -17,6 +17,7 @@
static char rcsid[] = "$Id$";
#endif
+#include <config.h>
#include "tailor.h"
#include "gzip.h"
#include "crypt.h"
@@ -35,6 +36,7 @@ static char rcsid[] = "$Id$";
#define LOCEXT 28 /* offset of extra field length */
#define LOCHDR 30 /* size of local header, including sig */
#define EXTHDR 16 /* size of extended local header, inc sig */
+#define RAND_HEAD_LEN 12 /* length of encryption random header */
/* Globals */
@@ -103,6 +105,7 @@ int unzip(in, out)
ulg orig_len = 0; /* original uncompressed length */
int n;
uch buf[EXTHDR]; /* extended local header */
+ int err = OK;
ifd = in;
ofd = out;
@@ -136,9 +139,6 @@ int unzip(in, out)
}
while (n--) {
uch c = (uch)get_byte();
-#ifdef CRYPT
- if (decrypt) zdecode(c);
-#endif
put_ubyte(c);
}
flush_window();
@@ -172,10 +172,14 @@ int unzip(in, out)
/* Validate decompression */
if (orig_crc != updcrc(outbuf, 0)) {
- error("invalid compressed data--crc error");
+ fprintf(stderr, "\n%s: %s: invalid compressed data--crc error\n",
+ progname, ifname);
+ err = ERROR;
}
- if (orig_len != (ulg)bytes_out) {
- error("invalid compressed data--length error");
+ if (orig_len != (ulg)(bytes_out & 0xffffffff)) {
+ fprintf(stderr, "\n%s: %s: invalid compressed data--length error\n",
+ progname, ifname);
+ err = ERROR;
}
/* Check if there are more entries in a pkzip file */
@@ -189,11 +193,12 @@ int unzip(in, out)
fprintf(stderr,
"%s: %s has more than one entry -- unchanged\n",
progname, ifname);
- exit_code = ERROR;
- ext_header = pkzip = 0;
- return ERROR;
+ err = ERROR;
}
}
ext_header = pkzip = 0; /* for next file */
- return OK;
+ if (err == OK) return OK;
+ exit_code = ERROR;
+ if (!test) abort_gzip();
+ return err;
}