From 51e35f35ae5ab0a90c30196d1f4f5c6d27438b05 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Thu, 28 Jun 2018 14:23:11 +0900 Subject: [PATCH] Imported Upstream version 610c15 Change-Id: Iaeafdb2d4683a17cf37a25f7813a6fccdf5f6e5d Signed-off-by: DongHun Kwak --- COPYING.OLD | 4 +- Contents | 3 +- History.610 | 25 +++++ INSTALL | 33 +++--- api.c | 14 ++- expand.c | 224 ++++++++++++++++++++++++++++++++++++++ extract.c | 61 ++++++++++- process.c | 178 +++++++++++++++++++++++++++++- tandem/README | 2 +- unix/Makefile | 6 +- unreduce.c | 38 ++++--- unzip.c | 286 ++++--------------------------------------------- unzpriv.h | 57 +++++++--- unzvers.h | 4 +- vms/DESCRIP_DEPS.MMS | 1 + vms/descrip_mkdeps.mms | 6 +- zip-comment.txt | 2 +- zipinfo.c | 177 +++++++++++++++--------------- 18 files changed, 698 insertions(+), 423 deletions(-) create mode 100644 expand.c diff --git a/COPYING.OLD b/COPYING.OLD index 9789207..0e9a9bf 100644 --- a/COPYING.OLD +++ b/COPYING.OLD @@ -2,7 +2,7 @@ __________________________________________________________________________ This is the Info-ZIP file COPYING.OLD (for UnZip) Last content update: 17 Jul 2000 - Last edit: 28 Jan 2013 + Last edit: 09 Jan 2015 __________________________________________________________________________ FIRST NOTE: @@ -56,7 +56,7 @@ __________________________________________________________________________ filename-mapping, text translation, ...; etc. As far as we can tell, only the core code of the Reduce method remained substantially similar to Mr. Smith's original source. As of UnZip 5.42, the complete - core code is now covered by the Info-ZIP Licence. Therefore, support + core code is now covered by the Info-ZIP License. Therefore, support for the Reduce method has been removed. The drop of the Reduce method should only affect some test archives. Reduce was never used in any publicly distributed Zip program. diff --git a/Contents b/Contents index 6008c6c..8917ffb 100644 --- a/Contents +++ b/Contents @@ -55,6 +55,7 @@ crypt.c Traditional zip encryption crypt.h Header file for crypt.c ebcdic.h Static lookup table for ASCII <-> EBCDIC translation envargs.c Read options from environment variables +expand.c Reduce compression (methods 2-5), Peter Backes (public domain) explode.c Implode compression (method 6) extract.c High-level extraction and decryption code fileio.c File I/O, password, various utilities @@ -72,7 +73,7 @@ timezone.h Header file for timezone.c ttyio.c Terminal I/O: echo, size; password, pager ttyio.h Header file for ttyio.c ubz2err.c Callback handler for fatal bzip2 errors (bzip2 support) -unreduce.c Reduce compression (methods 2-5), stub only +unreduce.c Reduce compression (methods 2-5), wrapper unshrink.c Shrink compression (method 1) unzip.c UnZip main(), usage and options code unzip.h Public part of main UnZip header file diff --git a/History.610 b/History.610 index 13b18f8..996e5c8 100644 --- a/History.610 +++ b/History.610 @@ -573,6 +573,27 @@ Features added (or removed): 6.10c13 (17 Dec 2014): - No news. +6.10c14 (03 Jan 2015): + - No news. + +6.10c15 (12 Jan 2015): + - Included public-domain code from Peter Backes for the (obsolete) + Reduce compression method. (Some minor changes were made to clear + some diagnostics from modern compilers, and to accommodate inclusion + by unreduce.c.) To enable Unreduce support using the public-domain + code, define the C macro USE_UNREDUCE_PUBLIC. To enable Unreduce + support using the copyrighted Unreduce code, define the C macro + USE_UNREDUCE_SMITH (or, for compatibility with old code and + documentation, USE_SMITH_CODE), and supply the source file + unreduce_full.c. See INSTALL for details. The C macro + COPYRIGHT_CLEAN has been removed from the code and from the "UnZip + special compilation options" ("-v") report. The new USE_UNREDUCE_xxx + macros appear instead. + http://sourceforge.net/p/infozip/patches/18/ + (api.c, COPYING.OLD, expand.c (new), extract.c, INSTALL, + unix/Makefile, unreduce.c, unzip.c, unzpriv.h, vms/descrip_deps.mms, + vms/descrip_mkdeps.mms) [Peter Backes, SMS] + Bugs fixed: @@ -1574,3 +1595,7 @@ Bugs fixed: _ Added more details to documentation on build customization. (INSTALL) [SMS] - Advanced copyright dates in messages to 2015. (unzip.c) [SMS] + +6.10c15 (10 Jan 2015) + - Spelling changes. (COPYING.OLD, tandem/README) [SMS] + - Removed some dead code. (unzip.c) [SMS] diff --git a/INSTALL b/INSTALL index dfd17af..b00b594 100644 --- a/INSTALL +++ b/INSTALL @@ -1,7 +1,7 @@ INSTALL -- Info-ZIP UnZip Installation Instructions =================================================== - UnZip version 6.10. Revised: 2015-01-03 + UnZip version 6.10. Revised: 2015-01-09 ------------------------------------------------------------------------ @@ -978,20 +978,6 @@ CHEAP_SFX_AUTORUN with the "-d " command line option, therefore CHEAP_SFX_AUTORUN implicitly sets the NO_SFX_EXDIR option (below). -COPYRIGHT_CLEAN (now default) -USE_SMITH_CODE - The last chunk of code in UnZip that was blatantly derived from Sam - Smith's unzip 2.0 (as in, "substantially similar") is in unreduce.c. - Because the Reduce compression method was only used by very early - PKZIP beta versions (0.9x), support for it is now omitted by default - (COPYRIGHT_CLEAN). To include support for Reduce compression, define - the C macro USE_SMITH_CODE, and replace the stub unreduce.c source - module with the separately distributed full source code module. Note - that this subjects your UnZip to any and all restrictions in Smith's - copyright. See the UnZip COPYING.OLD file for details. The source - code module unreduce.c is supplied in: - ftp://ftp.info-zip.org/pub/infozip/src/unreduce_full.zip - IZ_CRYPT_AES_WG (requires additional external code distribution) Enable WinZip/Gladman AES (strong) encryption support. Currently, this support is integrated in the Make procedures of MSDOS 32-bit @@ -1149,6 +1135,23 @@ UNIXBACKUP (default on OS/2, Unix, Windows) On target ports where UNIXBACKUP is enabled by default, the negated option, NO_UNIXBACKUP, may be used to disable this feature. +USE_UNREDUCE_PUBLIC +USE_UNREDUCE_SMITH + The Reduce compression method is now obsolete. It was used by very + early PKZIP beta versions (0.9x). By default, support for it is not + included in UnZip. If desired, Unreduce support can be provided + using either the original, copyrighted code from Samuel H. Smith, or + some newer, public-domain code from Peter Backes. + USE_UNREDUCE_PUBLIC enables Unreduce support using the public-domain + code. USE_UNREDUCE_SMITH enables Unreduce support using the + copyrighted code. The public-domain Unreduce source module + (expand.c) is included in the UnZip source kit. The copyrighted + source module (unreduce_full.c) is available separately in: + ftp://ftp.info-zip.org/pub/infozip/src/unreduce_full.zip + Note that using the copyrighted code subjects your UnZip to any and + all restrictions in Smith's copyright. See the UnZip COPYING.OLD + file for details. + VMS_TEXT_CONV (default everywhere except VMS) NO_VMS_TEXT_CONV VMS_TEXT_CONV enables conversion of some VMS-specific text file diff --git a/api.c b/api.c index a8b8f0f..a38e868 100644 --- a/api.c +++ b/api.c @@ -259,11 +259,10 @@ char *UzpFeatures() # ifdef PPMD_SUPPORT strcat( featurelist, ",ppmd"); # endif - strcat( featurelist, ";"); - -# ifdef COPYRIGHT_CLEAN - strcat( featurelist, "copyright_clean;"); +# if defined( USE_UNREDUCE_PUBLIC) || defined( USE_UNREDUCE_SMITH) + strcat( featurelist, ",unreduce;"); # endif + strcat( featurelist, ";"); # ifdef IZ_CRYPT_ANY @@ -389,6 +388,13 @@ char *UzpFeatures() strcat( featurelist, "use_ef_ut_time;"); # endif +# ifdef USE_UNREDUCE_PUBLIC + strcat( featurelist, "use_unreduce_public;"); +# endif +# ifdef USE_UNREDUCE_SMITH + strcat( featurelist, "use_unreduce_smith;"); +# endif + # ifdef USE_VFAT strcat( featurelist, "use_vfat;"); # endif diff --git a/expand.c b/expand.c new file mode 100644 index 0000000..6897b9a --- /dev/null +++ b/expand.c @@ -0,0 +1,224 @@ +/* Info-ZIP version 1.0 */ + +/* + * expand (unreduce) + * + * Written by Peter Backes, 2012 + * Public Domain + * + * This is a free replacement for "[t]he last chunk of code in UnZip + * that was blatantly derived from Sam Smith's unzip 2.0." The reduce + * algorithm was used only by PKZIP 0.90 and 0.92. To enable unreducing + * capability, define USE_UNREDUCE_PUBLIC (for example, by specifying + * LOCAL_UNZIP=-DUSE_UNREDUCE_PUBLIC to the Makefile). + * + * reduce was rarely ever used, and, in fact, the PKZIP 0.90 and 0.92 + * self-extracting distributions themselves (PKZ090.EXE and PKZ092.EXE) + * are the only easy to find files that actually make use of it. So + * this file might be handy only if you are into computer archeology and + * old software archives. + * + * + * "The Reducing algorithm is actually a combination of two + * distinct algorithms. The first algorithm compresses repeated + * byte sequences, and the second algorithm takes the compressed + * stream from the first algorithm and applies a probabilistic + * compression method." --APPNOTE.TXT + * + * + * + * NOTE: unreduce may or may not infinge or have been covered or + * be covered anytime in the future by patent restoration, by + * US patent 4,612,532, "Data compression apparatus and method," + * inventor Bacon, assignee Telebyte Corportion, filed Jun. 19, + * 1984, granted Sep. 16, 1986 (see compression-faq, section 7). + * + * ALL LIABILITY FOR USE OF THIS CODE IN VIOLATION OF APPLICABLE + * PATENT LAW IS HEREBY DISCLAIMED. + * + */ + + +#define __UNREDUCE_C +#define UNZIP_INTERNAL +#include "unzip.h" + +/* extend most significant bit to the right, at most one char, set + * least significant extended bit to 1 + */ +#define M_EXTR1C(j) (((j) | (j) >> 1) | ((j) | (j) >> 1) >> 2 \ + | (((j) | (j) >> 1) | ((j) |127) >> 2) >> 4) + +/* compute log2(n) for n=1,2,...,128. Stolen from ghostscript gxarith.h */ +#define M_L2C(n) ((unsigned int)(05637042010L >> ((((n) % 11) - 1) * 3)) & 7) + +#define LMASK 0x0f1f3f7f +/* function L(X): masks out the lower (8-CF) bits of X, where + * CF = compression factor + */ +#define M_L(cf,x) (LMASK >> ((cf-1)<<3) & (x)) +/* function F(X): 2 if all masked bits in L(X) are set, 3 otherwise */ +#define M_F(cf,x) (3 - (M_L(cf,0xff) == (x))) +/* function D(X,Y): upper CF bits of X concatenated with the bits of y+1 */ +#define M_D(cf,x,y) ((((x) << (cf)) & 0xf00) + (y) + 1) +/* B(N(j)) = bits needed to encode N(j)-1 */ +#define M_B(i) (M_L2C((M_EXTR1C((i)-1)&127)+1)+((unsigned)((i)-1)>127)) + +#define DLE 144 + +#define XREADBITS(nbits,zdest,stmt) READBITS(nbits,zdest) if (G.zipeof) stmt; + +#define SWSIZE M_D(cf, 255, 255) + +int unreduce(__G) + __GDEF +{ + int lc = 0; /* Last-Character */ + int state = 0; + int len, v; + int cf = G.lrec.compression_method - 1; + ulg rest = G.lrec.ucsize; + int outpos = 0, backptr; + int error; + int i; + /* number of followers N(j) */ + uch (*f_n)[256] = (uch (*)[256])(slide + SWSIZE); + /* follower set S(j)[0..N(j)-1] */ + uch (*f_s)[256][32] = (uch (*)[256][32])(slide + SWSIZE + sizeof *f_n); + + memzero(slide,SWSIZE); + + Trace((stderr, "unreduce()\ncompression factor %d\n", cf)); + Trace((stderr, "size1 %d size2 %d setlen %d\n", sizeof **f_s, + sizeof ***f_s, M_L2C(sizeof **f_s / sizeof ***f_s))); + /* get follower sets */ + for (i = 0; i < sizeof *f_n / sizeof **f_n; i++) { + int m, j = 255 - i; + XREADBITS(M_L2C(sizeof **f_s / sizeof ***f_s) + 1, + (*f_n)[j],return PK_OK) + Trace((stderr, "N(%d) = %d, S(%d) = {", j, (*f_n)[j], j)); + if ((*f_n)[j] > 32) + return PK_OK; + for (m = 0; m < (*f_n)[j]; m++) { + XREADBITS(8,(*f_s)[j][m], return PK_OK) + Trace((stderr, "%d, ", (*f_s)[j][m])); + } + Trace((stderr, "}\n")); + } + + /* expand file */ + while (rest) { + Trace((stderr, "N(%d) = %d ", lc, (*f_n)[lc])); + if (!(*f_n)[lc]) { + XREADBITS(8, lc, break) + Trace((stderr, "=> %d ", lc)); + } else { + shrint code; + XREADBITS(1, code, break) + if (code) { + XREADBITS(8, lc, break) + Trace((stderr, "1 => %d", lc)); + } else { + XREADBITS(M_B((*f_n)[lc]), code, break) + Trace((stderr, "0 %d %d ", + M_B((*f_n)[lc]), code)); + if (code >= (*f_n)[lc]) + break; + lc = (*f_s)[lc][code]; + Trace((stderr, "=> %d", lc)); + } + } + + Trace((stderr, "\t[%d] ", state)); + + switch (state) { + case 0: + if (lc != DLE) { + slide[outpos++] = lc; + rest--; + Trace((stderr, "%d/%d", outpos, SWSIZE)); + if (outpos == SWSIZE) { + if ((error = flush(__G__ slide, + (ulg)SWSIZE, 0))) + return error; + outpos = 0; + } + } else + state = 1; + Trace((stderr, "\n")); + break; + case 1: + if (lc) { + v = lc; + len = M_L(cf,v); + state = M_F(cf,len); + Trace((stderr, "len=%d", len)); + } else { + Trace((stderr, "%d/%d", outpos, SWSIZE)); + slide[outpos++] = DLE; + rest--; + if (outpos == SWSIZE) { + if ((error = flush(__G__ slide, + (ulg)SWSIZE, 0))) + return error; + + outpos = 0; + } + state = 0; + } + Trace((stderr, "\n")); + break; + case 2: + len += lc; + Trace((stderr, "+len=%d\n", len)); + state = 3; + break; + case 3: + backptr = outpos - M_D(cf,v,lc); + len += 3; + rest -= len > rest ? rest : len; + Trace((stderr, "%d <-%d[%d]-- %d/%d\n", backptr, + outpos - backptr,len, outpos, SWSIZE)); + if (backptr < 0) + backptr += SWSIZE; + + if (backptr + len > SWSIZE) { + len -= SWSIZE - backptr; + if (outpos >= backptr) { + while (outpos < SWSIZE) + slide[outpos++] + = slide[backptr++]; + if ((error = flush(__G__ slide, + (ulg)SWSIZE, 0))) + return error; + outpos = 0; + } + memmove(slide+outpos,slide+backptr, + SWSIZE - backptr); + outpos += SWSIZE - backptr; + backptr = 0; + } + if (outpos + len >= SWSIZE) { + len -= SWSIZE - outpos; + while (outpos < SWSIZE) + slide[outpos++] + = slide[backptr++]; + if ((error = flush(__G__ slide, + (ulg)SWSIZE, 0))) + return error; + outpos = 0; + } + while (len-- > 0) + slide[outpos++] + = slide[backptr++]; + + state = 0; + break; + } + } + if (outpos && (error = flush(__G__ slide, (ulg)outpos, 0))) + return error; + + return PK_OK; +} + diff --git a/extract.c b/extract.c index c7fd2e8..9318a54 100644 --- a/extract.c +++ b/extract.c @@ -1,5 +1,5 @@ /* - Copyright (c) 1990-2014 Info-ZIP. All rights reserved. + Copyright (c) 1990-2015 Info-ZIP. All rights reserved. See the accompanying file LICENSE, version 2009-Jan-02 or later (the contents of which are also included in unzip.h) for terms of use. @@ -1173,7 +1173,8 @@ int extract_or_test_files(__G) /* return PK-type error code */ # define UNKN_SHR FALSE /* Shrink (1) allowed. */ #endif -#ifdef COPYRIGHT_CLEAN /* Reduce (2-5) not allowed. */ +#if !defined( USE_UNREDUCE_PUBLIC) && !defined( USE_UNREDUCE_SMITH) + /* Reduce (2-5) not allowed. */ # define UNKN_RED (G.crec.compression_method >= REDUCED1 && \ G.crec.compression_method <= REDUCED4) #else @@ -1593,6 +1594,58 @@ static int extract_or_test_entrylist(__G__ numchunk, continue; /* go on */ } } + +#ifdef USE_EF_STREAM + + /* Process any EF_STREAM extra block. + * Proof of concept. Currently not actually used for anything. + */ +#define EF_STREAM_BM_SIZE 2 /* We currently expect only one, actually. */ + { + uch bitmap[ EF_STREAM_BM_SIZE]; + ext_local_file_hdr xlhdr; + char *cmnt; + int btmp_siz = EF_STREAM_BM_SIZE; + int sts; + + sts = ef_scan_for_stream( G.extra_field, + G.lrec.extra_field_length, + &btmp_siz, + &bitmap[ 0], + &xlhdr, + &cmnt); + + if (sts >= 0) + { + fprintf( stderr, " e_s_f_s() = %d.\n", sts); + fprintf( stderr, " btmp_len = %d.\n", btmp_siz); + fprintf( stderr, " bitmap[ 0] = %02x .\n", bitmap[ 0]); + + fprintf( stderr, + " xlhdr.version_made_by[ 0, 1] = %02x %02x.\n", + xlhdr.version_made_by[ 0], xlhdr.version_made_by[ 1]); + + fprintf( stderr, + " xlhdr.internal_file_attributes = %04x .\n", + xlhdr.internal_file_attributes); + + fprintf( stderr, + " xlhdr.external_file_attributes = %08x .\n", + xlhdr.external_file_attributes); + + fprintf( stderr, " xlhdr.file_comment_length = %d.\n", + xlhdr.file_comment_length); + + fprintf( stderr, " cmnt = %08x .\n", cmnt); + if (cmnt != NULL) + { + fprintf( stderr, + " cmnt: >%*s<.\n", xlhdr.file_comment_length, cmnt); + } + } + } +#endif /* def USE_EF_STREAM */ + #ifndef SFX /* Filename consistency checks must come after reading in the local * extra field, so that a UTF-8 entry name e.f. block has already @@ -3145,7 +3198,7 @@ static int extract_or_test_member(__G) /* return PK-type error code */ break; #endif /* !LZW_CLEAN */ -#ifndef COPYRIGHT_CLEAN +#if defined( USE_UNREDUCE_PUBLIC) || defined( USE_UNREDUCE_SMITH) case REDUCED1: case REDUCED2: case REDUCED3: @@ -3169,7 +3222,7 @@ static int extract_or_test_member(__G) /* return PK-type error code */ error = r; } break; -#endif /* !COPYRIGHT_CLEAN */ +#endif /* defined( USE_UNREDUCE_PUBLIC) || defined( USE_UNREDUCE_SMITH) */ #ifndef SFX /* Implode should have its own macro. */ case IMPLODED: diff --git a/process.c b/process.c index 128b894..034c731 100644 --- a/process.c +++ b/process.c @@ -1,5 +1,5 @@ /* - Copyright (c) 1990-2014 Info-ZIP. All rights reserved. + Copyright (c) 1990-2015 Info-ZIP. All rights reserved. See the accompanying file LICENSE, version 2009-Jan-02 or later (the contents of which are also included in unzip.h) for terms of use. @@ -25,6 +25,7 @@ process_local_file_hdr() getZip64Data() ef_scan_for_izux() + ef_scan_for_stream() getRISCOSexfield() ---------------------------------------------------------------------------*/ @@ -3596,3 +3597,178 @@ zvoid *getRISCOSexfield(ef_buf, ef_len) } #endif /* (RISCOS || ACORN_FTYPE_NFS) */ + + +#ifdef USE_EF_STREAM + +/*********************************/ +/* Function ef_scan_for_stream() */ +/*********************************/ + +/* 2015-01-08 SMS. New. + * + * Returns value -1 if EF_STREAM not found, 0 if EF_STREAM found and + * valid, positive if error. + * Returns bitmap in user's btmp[ *btmp_siz] array. + * Returns bitmap length in user's btmp_siz. + * Returns data in user's xlhdr structure. + * Returns comment pointer in user's cmnt pointer (not NUL-terminated, + * but length is in xlhdr.file_comment_length). cmnt may be NULL, if + * the user is not interested. + */ +unsigned ef_scan_for_stream( ef_ptr, ef_len, btmp_siz, btmp, xlhdr, cmnt) + ZCONST uch *ef_ptr; /* Buffer containing extra field. */ + long ef_len; /* Total length of extra field. */ + int *btmp_siz; /* Size of bitmap array. */ + uch *btmp; /* Bitmap (array). */ + ext_local_file_hdr *xlhdr; /* Extended local header data. */ + char **cmnt; /* File comment. */ +{ + unsigned eb_id; + long eb_len; + uch bitmap; + int bitmap_byte_max = 0; + int bitmap_byte; + int data_byte; + unsigned sts = -1; + +/*--------------------------------------------------------------------------- + This function scans the extra field for EF_STREAM. + ---------------------------------------------------------------------------*/ + + if ((ef_len == 0) || (ef_ptr == NULL)) + return sts; + + TTrace((stderr, + "\nef_scan_for_stream: scanning extra field of length %ld\n", ef_len)); + + while (ef_len >= EB_HEADSIZE) + { + eb_id = makeword( ef_ptr+ EB_ID); + eb_len = makeword( ef_ptr+ EB_LEN); + ef_ptr += EB_HEADSIZE; + ef_len -= EB_HEADSIZE; + + if (eb_len > ef_len) + { + /* Discovered some extra field inconsistency! */ + TTrace((stderr, + "ef_scan_for_stream: block length %ld > rest ef_size %ld\n", + eb_len, ef_len)); + sts = 1; + break; + } + + if (eb_id == EF_STREAM) + { + sts = 0; /* Indicate EF_STREAM found. */ + if (cmnt != NULL) + { + *cmnt = NULL; /* Clear comment pointer. */ + } + xlhdr->file_comment_length = 0; /* Clear comment length. */ + + /* Loop through (and save) the bitmap bytes. */ + data_byte = 0; + do + { + if (bitmap_byte_max >= eb_len) /* Stay within the block. */ + { + /* Out of data before end-of-bitmap. */ + TTrace((stderr, + "ef_scan_for_stream: No end-of-bitmap.\n")); + sts = 2; + break; + } + + /* If the user has space for another, then return a bitmap byte. */ + bitmap = *(ef_ptr+ (data_byte++)); + if (bitmap_byte_max < *btmp_siz) + { + btmp[ bitmap_byte_max++] = bitmap; + } + } while ((bitmap& EB_STREAM_EOB) != 0); /* Loop while more bitmap. */ + *btmp_siz = bitmap_byte_max; /* Return bitmap length. */ + + /* Loop through bitmap bytes. Stay within the extra block. */ + for (bitmap_byte = 0; bitmap_byte < bitmap_byte_max; bitmap_byte++) + { + bitmap = btmp[ bitmap_byte]; /* Next bitmap byte. */ + switch (bitmap_byte) + { + case 0: + if (bitmap& (1 << 0)) /* Version made by. */ + { + if (data_byte+ 2 > eb_len) /* Missing data. */ + { + sts = 3; + break; + } + xlhdr->version_made_by[ 0] = (ef_ptr+ data_byte)[ 0]; + xlhdr->version_made_by[ 1] = (ef_ptr+ data_byte)[ 1]; + data_byte += 2; + } + + if (bitmap& (1 << 1)) /* Internal file attributes. */ + { + if (data_byte+ 2 > eb_len) /* Missing data. */ + { + sts = 4; + break; + } + xlhdr->internal_file_attributes = makeword( ef_ptr+ data_byte); + data_byte += 2; + } + + if (bitmap& (1 << 2)) /* External file attributes. */ + { + if (data_byte+ 4 > eb_len) /* Missing data. */ + { + sts = 5; + break; + } + xlhdr->external_file_attributes = makelong( ef_ptr+ data_byte); + data_byte += 4; + } + + if (bitmap& (1 << 3)) /* File comment. */ + { + if (data_byte+ 2 > eb_len) /* Missing data. */ + { + sts = 6; + break; + } + xlhdr->file_comment_length = makeword( ef_ptr+ data_byte); + data_byte += 2; + if (xlhdr->file_comment_length > 0) + { + if (data_byte+ xlhdr->file_comment_length > + eb_len) /* Missing data. */ + { + sts = 7; + break; + } + if (cmnt != NULL) + { /* Set comment pointer. */ + *cmnt = (char *)(ef_ptr+ data_byte); + } + data_byte += xlhdr->file_comment_length; + } + } + + default: /* Past known bits. */ + break; + } /* switch */ + bitmap_byte++; /* Next bitmap index. */ + } /* for */ + } /* if (eb_id == EF_STREAM) */ + + /* Advance to the next extra field block. */ + ef_ptr += eb_len; + ef_len -= eb_len; + } /* while */ + + return sts; +} + +#endif /* def USE_EF_STREAM */ diff --git a/tandem/README b/tandem/README index 3fd5f1b..8495b0e 100644 --- a/tandem/README +++ b/tandem/README @@ -89,7 +89,7 @@ Stage 2 - (optional) retrieve source code (requires UNZIP on Tandem) - restore relevant files by running DOIT - replace references to $T with a collector on your system - replace references to SUPER.DAVES with whatever user id you use -- to compile run MAKE (compiles, accelerates, licences) +- to compile run MAKE (compiles, accelerates, licenses) - NOTE: Always run the accelerated object on TNS/R systems, otherwise it runs extremely slow. diff --git a/unix/Makefile b/unix/Makefile index c526080..bda9b37 100644 --- a/unix/Makefile +++ b/unix/Makefile @@ -1,6 +1,6 @@ #============================================================================== # unix/Makefile -# - For UnZip, fUnZip, UnZipSFX, and ZipInfo Revised: 2015-01-03 +# - For UnZip, fUnZip, UnZipSFX, and ZipInfo Revised: 2015-01-09 # # Copyright (c) 2004-2014 Info-ZIP. All rights reserved. # @@ -719,7 +719,7 @@ $(PROD)/ttyio.o: ttyio.c $(H_UNZIP) crypt.h ttyio.h zip.h $(PROD)/ubz2err.o: ubz2err.c $(H_UNZIP) $(CC) -c $(CF) -o $@ ubz2err.c -$(PROD)/unreduce.o: unreduce.c $(H_UNZIP) +$(PROD)/unreduce.o: unreduce.c $(H_UNZIP) expand.c $(CC) -c $(CF) -o $@ unreduce.c $(PROD)/unshrink.o: unshrink.c $(H_UNZIP) @@ -766,7 +766,7 @@ $(PROD)/ttyio_l.o: ttyio.c $(H_UNZIPL) crypt.h ttyio.h zip.h $(PROD)/ubz2err_l.o: ubz2err.c $(H_UNZIPL) $(CC) -c $(CF) -DDLL -o $@ ubz2err.c -$(PROD)/unreduce_l.o: unreduce.c $(H_UNZIPL) +$(PROD)/unreduce_l.o: unreduce.c $(H_UNZIPL) expand.c $(CC) -c $(CF) -DDLL -o $@ unreduce.c $(PROD)/unshrink_l.o: unshrink.c $(H_UNZIPL) diff --git a/unreduce.c b/unreduce.c index 4d1194f..f53cf4f 100644 --- a/unreduce.c +++ b/unreduce.c @@ -1,5 +1,5 @@ /* - Copyright (c) 1990-2002 Info-ZIP. All rights reserved. + Copyright (c) 1990-2015 Info-ZIP. All rights reserved. See the accompanying file LICENSE, version 2000-Apr-09 or later (the contents of which are also included in unzip.h) for terms of use. @@ -10,26 +10,24 @@ unreduce.c - Copyright-clean dummy module, without any real code. + Unreduce wrapper module. - If you really need unreduce support, replace this module by the full - source code, available as add-on package from our distribution site. + Define USE_UNREDUCE_SMITH to enable copyrighted Unreduce code (in + unreduce_full.c) from Samuel H. Smith. - ---------------------------------------------------------------------------*/ - - -#define __UNREDUCE_C /* identifies this source module */ -#define UNZIP_INTERNAL -#include "unzip.h" /* defines COPYRIGHT_CLEAN by default */ + Define USE_UNREDUCE_PUBLIC to enable public-domain Unreduce code (in + expand.c) from Peter Backes. + ---------------------------------------------------------------------------*/ -#ifndef COPYRIGHT_CLEAN - - /* This line is indented to hide the #error directive from pure traditional - * K&R C preprocessors. These do not recognize the #error directive, but - * they also recognize only lines that start with a '#' in column 1 as - * preprocessor directives. - */ - #error This dummy-module does not support the unreduce method! - -#endif /* !COPYRIGHT_CLEAN */ +#define __UNREDUCE_C_ /* identifies this source module */ + +#ifdef USE_UNREDUCE_PUBLIC +# include "expand.c" +#else +# ifdef USE_UNREDUCE_SMITH +# include "unreduce_full.c" +# else +int dummy_unreduce; /* Dummy declaration to quiet compilers. */ +# endif +#endif diff --git a/unzip.c b/unzip.c index 9df84cc..b42a290 100644 --- a/unzip.c +++ b/unzip.c @@ -481,10 +481,6 @@ static ZCONST char Far AsmInflateCodes[] = static ZCONST char Far Check_Versions[] = "CHECK_VERSIONS (Check VMS versions, build v. run-time)"; # endif -# ifdef COPYRIGHT_CLEAN -static ZCONST char Far Copyright_Clean[] = - "COPYRIGHT_CLEAN (PKZIP 0.9x unreducing method not supported)"; -# endif # ifdef DEBUG static ZCONST char Far UDebug[] = "DEBUG"; # endif @@ -493,7 +489,7 @@ static ZCONST char Far DebugTime[] = "DEBUG_TIME"; # endif # ifdef DEFLATE64_SUPPORT static ZCONST char Far Deflate64_Sup[] = - "DEFLATE64_SUPPORT (PKZIP 4.x Deflate64(tm) supported)"; + "DEFLATE64_SUPPORT (PKZIP 4.x Deflate64(tm) compression)"; # endif # ifdef DLL static ZCONST char Far Dll[] = @@ -512,7 +508,7 @@ static ZCONST char Far ux_Uid_Gid[] = # endif # ifdef LZW_CLEAN static ZCONST char Far LZW_Clean[] = - "LZW_CLEAN (PKZIP/Zip 1.x unshrink method not supported)"; + "LZW_CLEAN (PKZIP/Zip 1.x Shrink compression not supported)"; # endif # ifndef MORE static ZCONST char Far No_More[] = @@ -573,11 +569,16 @@ static ZCONST char Far Use_EF_UT_time[] = # endif # ifndef LZW_CLEAN static ZCONST char Far Unshrink_Sup[] = - "UNSHRINK_SUPPORT (PKZIP/Zip 1.x unshrinking method supported)"; + "UNSHRINK_SUPPORT (PKZIP/Zip 1.x Shrink compression)"; # endif -# ifndef COPYRIGHT_CLEAN -static ZCONST char Far Use_Smith_Code[] = - "USE_SMITH_CODE (PKZIP 0.9x unreducing method supported)"; +# ifdef USE_UNREDUCE_PUBLIC +static ZCONST char Far Use_Unreduce[] = + "USE_UNREDUCE_PUBLIC (PKZIP 0.9x Reduce compression, public-domain)"; +# else +# ifdef USE_UNREDUCE_SMITH +static ZCONST char Far Use_Unreduce[] = + "USE_UNREDUCE_SMITH (PKZIP 0.9x Reduce compression, (c) S. H. Smith)"; +# endif # endif # ifdef UNICODE_SUPPORT # ifdef UTF8_MAYBE_NATIVE @@ -705,7 +706,7 @@ static ZCONST char Far EnvGO32TMP[] = "GO32TMP"; # endif /* !defined( SFX) || defined( DIAG_SFX) */ # ifndef SFX -# ifdef COPYRIGHT_CLEAN /* Maintainer, not Smith copyright. */ +# ifndef USE_UNREDUCE_SMITH /* Maintainer, not Smith copyright. */ # ifdef VMSCLI /* Used in vms/cmdline.c, so not static in VMS CLI. "/lic" v. "--lic". */ ZCONST char Far UnzipUsageLine1[] = "\ @@ -716,7 +717,7 @@ UnZip %d.%d%d%s of %s, by Info-ZIP. Maintainer: \n\ UnZip %d.%d%d%s of %s, by Info-ZIP. Maintainer: \n\ Copyright (c) 1990-2015 Info-ZIP. For software license: unzip --license\n"; # endif /* def VMSCLI [else] */ -# else /* def COPYRIGHT_CLEAN */ /* Smith copyright, not maintainer. */ +# else /* ndef USE_UNREDUCE_SMITH */ /* Smith copyright, not maintainer. */ # ifdef VMSCLI /* Used in vms/cmdline.c, so not static in VMS CLI. "/lic" v. "--lic". */ ZCONST char Far UnzipUsageLine1[] = "\ @@ -727,7 +728,7 @@ static ZCONST char Far UnzipUsageLine1[] = "\ UnZip %d.%d%d%s of %s, by Info-ZIP. UnReduce (c) 1989 by S. H. Smith.\n\ Copyright (c) 1990-2015 Info-ZIP. For software license: unzip --license\n"; # endif /* def VMSCLI [else] */ -# endif /* def COPYRIGHT_CLEAN [else] */ +# endif /* ndef USE_UNREDUCE_SMITH [else] */ # define UnzipUsageLine1v UnzipUsageLine1 static ZCONST char Far UnzipUsageLine2v[] = "\ @@ -1208,33 +1209,6 @@ int unzip(__G__ argc, argv) } # endif /* def IZ_CRYPT_AES_WG */ -# ifdef DEBUG - /* 2004-11-30 SMS. - Test the NEXTBYTE macro for proper operation. - */ - { - int test_char; - static uch test_buf[2] = { 'a', 'b' }; - - G.inptr = test_buf; - G.incnt = 1; - - test_char = NEXTBYTE; /* Should get 'a'. */ - if (test_char == 'a') - { - test_char = NEXTBYTE; /* Should get EOF, not 'b'. */ - } - if (test_char != EOF) - { - Info(slide, 0x401, ((char *)slide, - "NEXTBYTE macro failed. Try compiling with ALT_NEXTBYTE defined?")); - - retcode = PK_COMPERR; - goto cleanup_and_exit; - } - } -# endif /* DEBUG */ - /*--------------------------------------------------------------------------- First figure out if we're running in UnZip mode or ZipInfo mode, and put the appropriate environment-variable options into the queue. Then rip @@ -1420,124 +1394,11 @@ int unzip(__G__ argc, argv) } # endif /* DOS_FLX_H68_NLM_OS2_W32 */ -# if 0 -/* G.wildzipfn now set in command line switch as first non-option argument */ -# ifndef SFX - G.wildzipfn = *argv++; -# endif -# endif - -# if (defined(SFX) && !defined(SFX_EXDIR)) /* only check for -x */ - -# if 0 - /* all this should be done in the options call now */ - - - G.filespecs = argc; - G.xfilespecs = 0; - - if (argc > 0) { - char **pp = argv-1; - - G.pfnames = argv; - while (*++pp) - if (strcmp(*pp, "-x") == 0) { - if (pp > argv) { - *pp = 0; /* terminate G.pfnames */ - G.filespecs = pp - G.pfnames; - } else { - G.pfnames = (char **)fnames; /* defaults */ - G.filespecs = 0; - } - G.pxnames = pp + 1; /* excluded-names ptr: _after_ -x */ - G.xfilespecs = argc - G.filespecs - 1; - break; /* skip rest of args */ - } - G.process_all_files = FALSE; - } else - G.process_all_files = TRUE; /* for speed */ -# endif - -# else /* !SFX || SFX_EXDIR */ /* check for -x or -d */ - -# if 0 - /* all this should be done in the options call now */ - - G.filespecs = argc; - G.xfilespecs = 0; - - if (argc > 0) { - int in_files=FALSE, in_xfiles=FALSE; - char **pp = argv-1; - - G.process_all_files = FALSE; - G.pfnames = argv; - while (*++pp) { - Trace((stderr, "pp - argv = %d\n", pp-argv)); -# ifdef CMS_MVS - if (!uO.exdir && STRNICMP(*pp, "-d", 2) == 0) { -# else - if (!uO.exdir && strncmp(*pp, "-d", 2) == 0) { -# endif - int firstarg = (pp == argv); - - uO.exdir = (*pp) + 2; - if (in_files) { /* ... zipfile ... -d exdir ... */ - *pp = (char *)NULL; /* terminate G.pfnames */ - G.filespecs = pp - G.pfnames; - in_files = FALSE; - } else if (in_xfiles) { - *pp = (char *)NULL; /* terminate G.pxnames */ - G.xfilespecs = pp - G.pxnames; - /* "... -x xlist -d exdir": nothing left */ - } - /* first check for "-dexdir", then for "-d exdir" */ - if (*uO.exdir == '\0') { - if (*++pp) - uO.exdir = *pp; - else { - Info(slide, 0x401, ((char *)slide, - LoadFarString(MustGiveExdir))); - /* don't extract here by accident */ - retcode = PK_PARAM; - goto cleanup_and_exit; - } - } - if (firstarg) { /* ... zipfile -d exdir ... */ - if (pp[1]) { - G.pfnames = pp + 1; /* argv+2 */ - G.filespecs = argc - (G.pfnames-argv); /* for now... */ - } else { - G.process_all_files = TRUE; - G.pfnames = (char **)fnames; /* GRR: necessary? */ - G.filespecs = 0; /* GRR: necessary? */ - break; - } - } - } else if (!in_xfiles) { - if (strcmp(*pp, "-x") == 0) { - in_xfiles = TRUE; - if (pp == G.pfnames) { - G.pfnames = (char **)fnames; /* defaults */ - G.filespecs = 0; - } else if (in_files) { - *pp = 0; /* terminate G.pfnames */ - G.filespecs = pp - G.pfnames; /* adjust count */ - in_files = FALSE; - } - G.pxnames = pp + 1; /* excluded-names ptr starts after -x */ - G.xfilespecs = argc - (G.pxnames-argv); /* anything left */ - } else - in_files = TRUE; - } - } - } else - G.process_all_files = TRUE; /* for speed */ -# endif /* 0 */ - - if (uO.exdir != (char *)NULL && !G.extract_flag) /* -d ignored */ +# if !defined( SFX) || defined( SFX_EXDIR) + if (uO.exdir != (char *)NULL && !G.extract_flag) + /* Have "-d exdir", but not actually extracting, so -d is ignored. */ Info(slide, 0x401, ((char *)slide, LoadFarString(NotExtracting))); -# endif /* ?(SFX && !SFX_EXDIR) */ +# endif /* !defined( SFX) || defined( SFX_EXDIR) */ # ifdef UNICODE_SUPPORT /* set Unicode-escape-all if option -U used */ @@ -1561,7 +1422,6 @@ int unzip(__G__ argc, argv) # endif # endif /* def KFLAG */ - /*--------------------------------------------------------------------------- Okey dokey, we have everything we need to get started. Let's roll. ---------------------------------------------------------------------------*/ @@ -1580,37 +1440,10 @@ cleanup_and_exit: } # endif -# if 0 - /* 2012-12-11 SMS. - * Disabled call of free_G_buffers() from - * process.c:process_zipfiles(), so now DESTROYGLOBALS() should do all - * the work (if any). - * - * On the other hand, the revised/reallocated argv[] is known only - * locally, so we should free it. - */ - /* 2012-12-10 SMS. - * This code appears to be goofy/redundant. - * Normally, process.c:process_zipfiles() - * calls process.c:free_G_buffers(), which, "#ifdef MALLOC_WORK", - * frees G.area.Slide, just like here. (With REENTRANT defined, - * DESTROYGLOBALS() includes at least one call to free_G_buffers(), so - * the "!defined(REENTRANT)" condition makes some sense, but why free - * this stuff and not anything else, if not REENTRANT?) - */ -# if defined(MALLOC_WORK) && !defined(REENTRANT) - if (G.area.Slide != (uch *)NULL) { - izu_free(G.area.Slide); - G.area.Slide = (uch *)NULL; - } -# endif /* defined(MALLOC_WORK) && !defined(REENTRANT) */ -# endif /* 0 */ - # ifdef REENTRANT free_args( argv); # endif /* def REENTRANT */ - # if (defined(MSDOS) && !defined(SFX) && !defined(WINDLL)) if (retcode != PK_OK) check_for_windows("UnZip"); @@ -1621,8 +1454,6 @@ cleanup_and_exit: - - # if (defined(REENTRANT) && !defined(NO_EXCEPT_SIGNALS)) /*******************************/ /* Function setsignalhandler() */ @@ -2693,26 +2524,6 @@ int uz_opts(__G__ pargc, pargv) } in_xfiles_count++; value = NULL; /* In use. Don't free it. */ - -# if 0 -# ifdef SFX - /* now get -x list one entry at a time */ - - - - /* when 'x' is the only option in this argument, and the - * next arg is not an option, assume this initiates an - * exclusion list (-x xlist): terminate option-scanning - * and leave uz_opts with argv still pointing to "-x"; - * the xlist is processed later - */ - if (s - argv[0] == 2 && *s == '\0' && - argc > 1 && argv[1][0] != '-') { - /* break out of nested loops without "++argv;--argc" */ - goto opts_done; - } -# endif /* def SFX */ -# endif /* 0 */ break; # if defined(RESTORE_UIDGID) || defined(RESTORE_ACL) case ('X'): /* restore owner/group (more?) info (need privs?) */ @@ -2969,22 +2780,6 @@ int uz_opts(__G__ pargc, pargv) # endif /* defined( SFX) && defined( DIAG_SFX) */ } -#if 0 /* Duplicate below. */ -# ifdef SFX - /* print our banner unless we're being fairly quiet */ - if (uO.qflag < 2) - Info(slide, (uzo_err ? 1 : 0), - ((char *)slide, LoadFarString(UnzipSFXBanner), - UZ_MAJORVER, UZ_MINORVER, UZ_PATCHLEVEL, UZ_BETALEVEL, - LoadFarStringSmall(VersionDate))); -# ifdef BETA - /* always print the beta warning: no unauthorized distribution!! */ - Info(slide, (uzo_err ? 1 : 0), - ((char *)slide, LoadFarString(BetaVersion), "\n", "SFX")); -# endif /* def BETA */ -# endif /* def SFX */ -#endif /* 0 Duplicate below. */ - if (uO.cflag || uO.tflag || uO.vflag || uO.zflag # ifdef TIMESTAMP || uO.T_flag @@ -2994,12 +2789,6 @@ int uz_opts(__G__ pargc, pargv) else G.extract_flag = TRUE; -# if 0 -# ifdef SFX -opts_done: /* yes, very ugly...but only used by UnZipSFX with -x xlist */ -# endif /* def SFX */ -# endif /* 0 */ - if (showhelp > 0) { /* just print help message and quit */ *pargc = -1; # ifndef SFX @@ -3770,19 +3559,6 @@ static void show_options(__G) char val_type[5]; char neg[2]; -#if 0 - struct option_struct { - int option_group; /* either UZO for UnZip or ZIO for ZipInfo syntax */ - char Far *shortopt; /* pointer to short option string */ - char Far *longopt; /* pointer to long option string */ - int value_type; /* from above */ - int negatable; /* from above */ - unsigned long option_ID; /* value returned by get_option when this option - is found */ - char Far *name; /* optional string for option returned on some - errors */ -#endif /* 0 */ - sprintf(optiontext, "%s\n\n%s\n%s", "Available options on this system", "UNZ = UnZip option, INF = ZipInfo option", @@ -3934,11 +3710,6 @@ static void show_version_info(__G) LoadFarStringSmall(Check_Versions))); ++numopts; # endif -# ifdef COPYRIGHT_CLEAN - Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat), - LoadFarStringSmall(Copyright_Clean))); - ++numopts; -# endif # ifdef DEBUG Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat), LoadFarStringSmall(UDebug))); @@ -4049,11 +3820,6 @@ static void show_version_info(__G) LoadFarStringSmall(Use_EF_UT_time))); ++numopts; # endif -# ifndef COPYRIGHT_CLEAN - Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat), - LoadFarStringSmall(Use_Smith_Code))); - ++numopts; -# endif # ifndef LZW_CLEAN Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat), LoadFarStringSmall(Unshrink_Sup))); @@ -4148,6 +3914,11 @@ static void show_version_info(__G) (char *)(slide+256))); ++numopts; # endif /* def PPMD_SUPPORT */ +# if defined( USE_UNREDUCE_PUBLIC) || defined( USE_UNREDUCE_SMITH) + Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat), + LoadFarStringSmall(Use_Unreduce))); + ++numopts; +# endif # ifdef VMS_TEXT_CONV Info(slide, 0, ((char *)slide, LoadFarString(CompileOptFormat), LoadFarStringSmall(VmsTextConv))); @@ -5659,17 +5430,6 @@ unsigned long get_option(__G__ option_group, pargs, argc, argnum, optchar, value break; } } - -#if 0 - /* argument file code left out - so for now let filenames start with @ - */ - - } else if (allow_arg_files && arg[0] == '@') { - /* arg file */ - oERR(PK_PARMS, no_arg_files_err); -#endif /* 0 */ - } else { /* non-option */ if (enable_permute) { diff --git a/unzpriv.h b/unzpriv.h index 4ac907f..cd1e9cf 100644 --- a/unzpriv.h +++ b/unzpriv.h @@ -1,5 +1,5 @@ /* - Copyright (c) 1990-2014 Info-ZIP. All rights reserved. + Copyright (c) 1990-2015 Info-ZIP. All rights reserved. See the accompanying file LICENSE, version 2009-Jan-02 or later (the contents of which are also included in unzip.h) for terms of use. @@ -1236,20 +1236,30 @@ void izu_md_check( void); # undef TIMESTAMP #endif +/* Accommodate old macro: USE_SMITH_CODE. */ +#if defined( USE_SMITH_CODE) && !defined( USE_UNREDUCE_SMITH) +# define USE_UNREDUCE_SMITH +#endif + +/* Disallow USE_UNREDUCE_PUBLIC and USE_UNREDUCE_SMITH together. */ +#if defined( USE_UNREDUCE_PUBLIC) && defined( USE_UNREDUCE_SMITH) + /* Indent to accommodate old compilers. */ + # error USE_UNREDUCE_PUBLIC USE_UNREDUCE_SMITH both defined. +#endif + /* For SFX, disable Reduce and Shrink compression methods. */ #ifdef SFX -# ifndef COPYRIGHT_CLEAN -# define COPYRIGHT_CLEAN /* Disable Reduce. */ +# ifdef USE_UNREDUCE_PUBLIC +# undef USE_UNREDUCE_PUBLIC /* Disable public-domain Reduce. */ +# endif +# ifdef USE_UNREDUCE_SMITH +# undef USE_UNREDUCE_SMITH /* Disable Smith copyrighted Reduce. */ # endif # ifndef LZW_CLEAN # define LZW_CLEAN /* Disable Shrink. */ # endif #endif -#if (!defined(COPYRIGHT_CLEAN) && !defined(USE_SMITH_CODE)) -# define COPYRIGHT_CLEAN -#endif - /* The LZW patent is expired worldwide since 2004-Jul-07, so * UNSHRINK_SUPPORT is now enabled by default. See unshrink.c. */ @@ -2108,7 +2118,7 @@ struct file_list { #define EF_UNICOMNT 0x6375 /* Info-ZIP Unicode Comment ("uc") */ #define EF_BEOS 0x6542 /* BeOS ("Be") */ #define EF_THEOS 0x6854 /* Jean-Michel Dubois Theos "Th" */ -#define EF_LHDREXTN 0x6c65 /* Local header extension ("el") */ +#define EF_STREAM 0x6c78 /* Extended Local Header (Stream) ("xl") */ #define EF_UNIPATH 0x7075 /* Info-ZIP Unicode Path ("up") */ #define EF_ASIUNIX 0x756e /* ASi Unix ("nu") */ #define EF_IZUNIX2 0x7855 /* Info-ZIP second Unix[2] ("Ux") */ @@ -2128,7 +2138,7 @@ struct file_list { #define EB_ID 0 /* offset of block ID in header */ #define EB_LEN 2 /* offset of data length field in header */ #define EB_UCSIZE_P 0 /* offset of ucsize field in compr. data */ -#define EB_CMPRHEADLEN 6 /* lenght of compression header */ +#define EB_CMPRHEADLEN 6 /* length of compression header */ #define EB_UX_MINLEN 8 /* minimal "UX" field contains atime, mtime */ #define EB_UX_FULLSIZE 12 /* full "UX" field (atime, mtime, uid, gid) */ @@ -2179,6 +2189,7 @@ struct file_list { #define EB_IZVMS_BC00 1 /* 0byte -> 0bit compression */ #define EB_IZVMS_BCDEFL 2 /* Deflated */ +#define EB_STREAM_EOB 0x80 /* Stream EF End-of-bitmap flag. */ /*--------------------------------------------------------------------------- True sizes of the various headers (excluding their 4-byte signatures), @@ -2541,7 +2552,7 @@ typedef struct VMStimbuf { Please note that the structure members are now reordered by size (top-down), to prevent internal padding and optimize memory usage! */ - typedef struct local_file_header { /* LOCAL */ + typedef struct local_file_header { /* LOCAL */ zusz_t csize; zusz_t ucsize; ulg last_mod_dos_datetime; @@ -2553,7 +2564,15 @@ typedef struct VMStimbuf { ush extra_field_length; } local_file_hdr; - typedef struct central_directory_file_header { /* CENTRAL */ + typedef struct ext_local_file_header { /* EXT. LOCAL (strm) */ + ulg external_file_attributes; + zuvl_t disk_number_start; + ush file_comment_length; + ush internal_file_attributes; + uch version_made_by[2]; + } ext_local_file_hdr; + + typedef struct central_directory_file_header { /* CENTRAL */ zusz_t csize; zusz_t ucsize; zusz_t relative_offset_local_header; @@ -2571,7 +2590,7 @@ typedef struct VMStimbuf { ush file_comment_length; } cdir_file_hdr; - typedef struct end_central_dir_record { /* END CENTRAL */ + typedef struct end_central_dir_record { /* END CENTRAL */ zusz_t size_central_directory; zusz_t offset_start_central_directory; zucn_t num_entries_centrl_dir_ths_disk; @@ -2686,6 +2705,14 @@ int getZip64Data OF((__GPRO__ ZCONST uch *ef_buf, unsigned ef_scan_for_izux OF((ZCONST uch *ef_buf, long ef_len, int ef_is_c, ulg dos_mdatetime, iztimes *z_utim, ulg *z_uidgid)); + +#ifdef USE_EF_STREAM +unsigned ef_scan_for_stream OF((ZCONST uch *ef_ptr, long ef_len, + int *btmp_siz, uch *btmp, + ext_local_file_hdr *xlhdr, + char **cmnt)); +#endif /* def USE_EF_STREAM */ + #ifdef IZ_CRYPT_AES_WG int ef_scan_for_aes OF((ZCONST uch *ef_buf, long ef_len, ush *vers, ush *vend, @@ -2845,11 +2872,9 @@ int huft_build OF((__GPRO__ ZCONST unsigned *b, unsigned n, int inflate_free OF((__GPRO)); /* inflate.c */ #endif /* ?USE_ZLIB */ #if (!defined(SFX) && !defined(FUNZIP)) -#ifndef COPYRIGHT_CLEAN +#if defined( USE_UNREDUCE_PUBLIC) || defined( USE_UNREDUCE_SMITH) int unreduce OF((__GPRO)); /* unreduce.c */ -/* static void LoadFollowers OF((__GPRO__ f_array *follower, uch *Slen)); - * unreduce.c */ -#endif /* !COPYRIGHT_CLEAN */ +#endif /* defined( USE_UNREDUCE_PUBLIC) || defined( USE_UNREDUCE_SMITH) */ #ifndef LZW_CLEAN int unshrink OF((__GPRO)); /* unshrink.c */ /* static void partial_clear OF((__GPRO)); * unshrink.c */ diff --git a/unzvers.h b/unzvers.h index 027c930..8922acb 100644 --- a/unzvers.h +++ b/unzvers.h @@ -24,8 +24,8 @@ # endif # ifdef BETA -# define UZ_BETALEVEL "c14 BETA" -# define UZ_VERSION_DATE "05 Jan 2015" /* Internal beta version. */ +# define UZ_BETALEVEL "c15 BETA" +# define UZ_VERSION_DATE "13 Jan 2015" /* Internal beta version. */ # else # define UZ_BETALEVEL "" # define UZ_VERSION_DATE "?? ??? 2015" /* Official release version. */ diff --git a/vms/DESCRIP_DEPS.MMS b/vms/DESCRIP_DEPS.MMS index 59bb995..1a8f4fc 100644 --- a/vms/DESCRIP_DEPS.MMS +++ b/vms/DESCRIP_DEPS.MMS @@ -1125,6 +1125,7 @@ $$$$ THIS DESCRIPTION FILE IS NOT INTENDED TO BE USED THIS WAY. [.$(DEST)]UBZ2ERR_L.OBJ : [.SZIP]CPUARCH.H .ENDIF # LZMA_PPMD [.$(DEST)]UNREDUCE.OBJ : []UNREDUCE.C +[.$(DEST)]UNREDUCE.OBJ : []EXPAND.C [.$(DEST)]UNREDUCE.OBJ : []UNZIP.H [.$(DEST)]UNREDUCE.OBJ : []UNZPRIV.H [.$(DEST)]UNREDUCE.OBJ : [.VMS]VMSCFG.H diff --git a/vms/descrip_mkdeps.mms b/vms/descrip_mkdeps.mms index 2940574..d532ced 100644 --- a/vms/descrip_mkdeps.mms +++ b/vms/descrip_mkdeps.mms @@ -2,10 +2,10 @@ # # UnZip 6.10 for VMS -- MMS Dependency Description File. # -# Last revised: 2014-10-19 +# Last revised: 2015-01-09 # #---------------------------------------------------------------------- -# Copyright (c) 2004-2014 Info-ZIP. All rights reserved. +# Copyright (c) 2004-2015 Info-ZIP. All rights reserved. # # See the accompanying file LICENSE, version 2009-Jan-2 or later (the # contents of which are also included in zip.h) for terms of use. If, @@ -18,7 +18,7 @@ # is not specified. Typical usage: # # $ L_U = "CRYPT_AES_WG_SFX, BZIP2_SFX, USE_OWN_CRCTAB,"+ - -# " LZMA_SFX, PPMD_SFX, API_DOC, MEMDIAG" +# " LZMA_SFX, PPMD_SFX, API_DOC, MEMDIAG, USE_UNREDUCE_PUBLIC" # $ MMS /EXTEND /DESCRIP = [.VMS]DESCRIP_MKDEPS.MMS /SKIP - # /MACRO = (AES_WG=1, IZ_BZIP2=iz_bzip2, IZ_ZLIB=iz_zlib, - # LIBUNZIP=1, "LOCAL_UNZIP=''L_U'") diff --git a/zip-comment.txt b/zip-comment.txt index 6997496..18d27e7 100644 --- a/zip-comment.txt +++ b/zip-comment.txt @@ -1,5 +1,5 @@ -Info-Zip UnZip -- Source kit. Version 6.10c14 (BETA) 05 Jan 2015. +Info-Zip UnZip -- Source kit. Version 6.10c15 (BETA) 13 Jan 2015. See enclosed files INSTALL, LICENSE, and README. For information on Info-Zip UnZip and Zip: diff --git a/zipinfo.c b/zipinfo.c index 2a0cc29..3e1e76e 100644 --- a/zipinfo.c +++ b/zipinfo.c @@ -1,5 +1,5 @@ /* - Copyright (c) 1990-2014 Info-ZIP. All rights reserved. + Copyright (c) 1990-2015 Info-ZIP. All rights reserved. See the accompanying file LICENSE, version 2009-Jan-02 or later (the contents of which are also included in unzip.h) for terms of use. @@ -363,7 +363,7 @@ static ZCONST char Far efTandem[] = "Tandem NSK"; static ZCONST char Far efTheos[] = "Theos"; static ZCONST char Far efAES[] = "AES_WG encrypt"; static ZCONST char Far efJavaCAFE[] = "Java CAFE"; -static ZCONST char Far efLHdrExtn[] = "Local Hdr Ext'n"; +static ZCONST char Far efStream[] = "Ext'd Lcl Hdr (stream)"; static ZCONST char Far efUnknown[] = "unknown"; static ZCONST char Far OS2EAs[] = ".\n\ @@ -435,9 +435,9 @@ static ZCONST char Far MD5data[] = ".\n\ static ZCONST char Far First20[] = ". The first\n 20 are: "; static ZCONST char Far ColonIndent[] = ":\n "; static ZCONST char Far efFormat[] = " %02x"; -static ZCONST char Far efLHdrExtnBitMap[] = " Bit map:"; -static ZCONST char Far efLHdrExtnBitMapByte[] = " %02x"; -static ZCONST char Far efLHdrExtnBitMapEol[] = "\n"; +static ZCONST char Far efStreamBitMap[] = " Bit map:"; +static ZCONST char Far efStreamBitMapByte[] = " %02x"; +static ZCONST char Far efStreamBitMapEol[] = "\n"; static ZCONST char Far AesExtraField[] = ".\n\ Vers: %s, Vend ID: %c%c, Mode: %s, Cmpr mthd: %s"; @@ -1785,7 +1785,8 @@ static int zi_long(__G__ pEndprev, error_in_archive) Info(slide, 0, ((char *)slide, LoadFarString(ExtraFields))); - while (ef_len >= EB_HEADSIZE) { + while (ef_len >= EB_HEADSIZE) + { eb_id = makeword(&ef_ptr[EB_ID]); eb_len = makeword(&ef_ptr[EB_LEN]); ef_ptr += EB_HEADSIZE; @@ -1916,8 +1917,8 @@ static int zi_long(__G__ pEndprev, error_in_archive) case EF_JAVA: ef_fieldname = efJavaCAFE; break; - case EF_LHDREXTN: - ef_fieldname = efLHdrExtn; + case EF_STREAM: + ef_fieldname = efStream; break; default: ef_fieldname = efUnknown; @@ -2268,92 +2269,94 @@ static int zi_long(__G__ pEndprev, error_in_archive) md5)); break; } /* else: fall through !! */ - case EF_LHDREXTN: - { - long eb_ndx = 0; - int eb_state = -1; - uch bit_mask; - unsigned hnum = (unsigned)-1; - unsigned hver; - - Info( slide, 0, ((char *)slide, - LoadFarString( efLHdrExtnBitMap))); - while (eb_ndx < eb_len) - { - switch (eb_state) + break; + case EF_STREAM: /* (Not expected in the central directory.) */ { - case -1: /* Seeking end of bit mask. */ - Info( slide, 0, ((char *)slide, - LoadFarString( efLHdrExtnBitMapByte), - *(ef_ptr+ eb_ndx))); - if ((*(ef_ptr+ eb_ndx)& 0x80) == 0) + long eb_ndx = 0; + int eb_state = -1; + uch bit_mask; + unsigned hnum = (unsigned)-1; + unsigned hver; + + Info( slide, 0, ((char *)slide, + LoadFarString( efStreamBitMap))); + while (eb_ndx < eb_len) + { + switch (eb_state) { - eb_state = 1; - eb_ndx++; - bit_mask = *ef_ptr; - Info( slide, 0, ((char *)slide, - LoadFarString( efLHdrExtnBitMapEol))); - } - break; - case 0: /* bit_mask[ 0]. */ - if (bit_mask& 0x01) - { /* Version Made By. */ - if (eb_ndx+ 2 <= eb_len) - { - hver = *(ef_ptr+ eb_ndx); - hnum = *(ef_ptr+ eb_ndx+ 1); - zi_vers_made_by( __G__ 1, hnum, hver); - eb_ndx += 2; - } - else - break; - } - if (bit_mask& 0x02) - { /* Internal File Atributes. */ - if (eb_ndx+ 2 <= eb_len) - { - iattr = makeword( ef_ptr+ eb_ndx); - zi_long_intern_attr( __G__ 1, iattr); - eb_ndx += 2; - } - else - break; - } - if (bit_mask& 0x04) - { /* External File Atributes. */ - if (eb_ndx+ 4 <= eb_len) - { - xattr = makelong( ef_ptr+ eb_ndx); - if (hnum != (unsigned)-1) - { /* Must know host type for ext attr. */ - zi_long_extern_attr( __G__ 1, hnum, xattr); + case -1: /* Seeking end of bit mask. */ + Info( slide, 0, ((char *)slide, + LoadFarString( efStreamBitMapByte), + *(ef_ptr+ eb_ndx))); + if ((*(ef_ptr+ eb_ndx)& EB_STREAM_EOB) == 0) + { + eb_state = 1; + eb_ndx++; + bit_mask = *ef_ptr; + Info( slide, 0, ((char *)slide, + LoadFarString( efStreamBitMapEol))); } - eb_ndx += 4; - } - else break; - } - if (bit_mask& 0x08) - { - if (eb_ndx+ 2 <= eb_len) - { - fc_len = makeword( ef_ptr+ eb_ndx); - eb_ndx += 2; - if (eb_ndx+ (long)fc_len <= eb_len) + case 0: /* bit_mask[ 0]. */ + if (bit_mask& (1 << 0)) + { /* Version Made By. */ + if (eb_ndx+ 2 <= eb_len) + { + hver = *(ef_ptr+ eb_ndx); + hnum = *(ef_ptr+ eb_ndx+ 1); + zi_vers_made_by( __G__ 1, hnum, hver); + eb_ndx += 2; + } + else + break; + } + if (bit_mask& (1 << 1)) + { /* Internal File Atributes. */ + if (eb_ndx+ 2 <= eb_len) + { + iattr = makeword( ef_ptr+ eb_ndx); + zi_long_intern_attr( __G__ 1, iattr); + eb_ndx += 2; + } + else + break; + } + if (bit_mask& (1 << 2)) + { /* External File Atributes. */ + if (eb_ndx+ 4 <= eb_len) + { + xattr = makelong( ef_ptr+ eb_ndx); + if (hnum != (unsigned)-1) + { /* Must know host type for ext attr. */ + zi_long_extern_attr( __G__ 1, hnum, xattr); + } + eb_ndx += 4; + } + else + break; + } + if (bit_mask& (1 << 3)) { - eb_ndx += fc_len; + if (eb_ndx+ 2 <= eb_len) + { + fc_len = makeword( ef_ptr+ eb_ndx); + eb_ndx += 2; + if (eb_ndx+ (long)fc_len <= eb_len) + { + eb_ndx += fc_len; + } + else + break; + } + else + break; } - else - break; - } - else + default: break; - } - default: - break; - } /* switch (eb_state) */ - } /* while (eb_ndx < eb_len) */ - } /* case EF_LHDREXTN */ + } /* switch (eb_state) */ + } /* while (eb_ndx < eb_len) */ + } /* case EF_STREAM */ + break; default: ef_default_display: -- 2.7.4