Index: README.CR =================================================================== RCS file: README.CR diff -N README.CR --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ README.CR 8 Mar 2005 03:17:09 -0000 1.1 @@ -0,0 +1,111 @@ +_____________________________________________________________________________ + + This is Info-ZIP's README.CR for zcrypt29.zip, last updated 22 April 2000. +_____________________________________________________________________________ + + +The files described below contain the encryption/decryption code for Zip 2.3, +UnZip 5.4, and WiZ 5.0 (and later). They constitute only an add-on to what +used to be referred to as the "exportable versions" (generally named zip23.zip, +unzip540.tar.Z, and wiz500.zip) and cannot be used without the complete Zip, +UnZip, or WiZ packages. Newer versions of the packages, such as UnZip 5.41 +and WiZ 5.01, already include the full encryption/decryption source code; for +other packages, check the comments at the top of crypt.c and crypt.h to see. + +As of version 2.9, this encryption source code is copyrighted by Info-ZIP; +see the enclosed LICENSE file for details. Older versions remain in the pub- +lic domain. Zcrypt was originally written in Europe and, as of April 2000, +can be freely distributed from the US as well as other countries. (The +ability to export from the US is new and is due to a change in the Bureau +of Export Administration's regulations, as published in Volume 65, Number +10, of the Federal Register [14 January 2000]. Info-ZIP filed the required +notification via e-mail on 9 April 2000; see the USexport.msg file in this +archive. Note that the exemption covers only source code, not compiled +binaries.) + + LIKE ANYTHING ELSE THAT IS FREE, ZIP, UNZIP AND THEIR ASSOCIATED + UTILITIES ARE PROVIDED AS IS AND COME WITH NO WARRANTY OF ANY KIND, + EITHER EXPRESSED OR IMPLIED. IN NO EVENT WILL THE AUTHORS BE LIABLE + FOR ANY DAMAGES RESULTING FROM THE USE OF THIS SOFTWARE. + +The encryption code is a direct transcription of the algorithm from +Roger Schlafly, described by Phil Katz in the file appnote.txt. This +file is distributed with the PKZIP program (even in the version without +encryption capabilities). Note that the encryption will probably resist +attacks by amateurs if the password is well chosen and long enough (at +least 8 characters) but it will probably not resist attacks by experts. +Paul Kocher has made available information concerning a known-plaintext +attack for the PKWARE encryption scheme; see http://www.cryptography.com/ +for details.) Short passwords consisting of lowercase letters only can be +recovered in a few hours on any workstation. But for casual cryptography +designed to keep your mother from reading your mail, it's OK. + +For more serious encryption, check into PGP (Pretty Good Privacy), a +public-key-based encryption system available from various Internet sites. +PGP has Zip and UnZip built into it. The most recent version at the time +this was written was 6.5, although older versions are still widespread. + +Zip 2.3x and UnZip 5.4x are compatible with PKZIP 2.04g. (Thanks to Phil +Katz for accepting our suggested minor changes to the zipfile format.) + +IMPORTANT NOTE: + + Zip archives produced by Zip 2.0 or later must not be *updated* by + Zip 1.1 or PKZIP 1.10 or PKZIP 1.93a, if they contain encrypted members + or if they have been produced in a pipe or on a non-seekable device. + The old versions of Zip or PKZIP would destroy the zip structure. The + old versions can list the contents of the zipfile but cannot extract + it anyway (because of the new compression algorithm). If you do not + use encryption and compress regular disk files, you need not worry about + this problem. + + +Contents: + + file what it is + ---- ---------- + README.CR this file + LICENSE Info-ZIP license (terms of reuse and redistribution) + USexport.msg export notice sent to US Bureau of Export Administration + WHERE where Zip/UnZip/WiZ and related utilities can be found + crypt.c code for encryption and decryption + crypt.h code for encryption and decryption + file_id.diz description file for some BBSes + +All of the files are in Unix (LF only) format. On MSDOS systems, you +can use the -a option of UnZip to convert the source files to CRLF +format. This is only necessary if you wish to edit the files -- they +will compile as is with Microsoft C and Turbo/Borland C++ 1.0 or +later. However, you will have to convert the files (using "unzip -a") +to the CRLF format to compile with the older Turbo C 1.0 or 2.0. You +should be able to find Zip and UnZip in the same place you found this +(see ftp://ftp.info-zip.org/pub/infozip/Info-ZIP.html or the file +"WHERE" for details). + +To use the zcrypt sources: + + (1) Get the main sources (e.g., Zip 2.3) and unpack into a working + directory, as usual. + + (2) Overwrite the dummy crypt.c and crypt.h from the main sources with + the versions from this package. If you want to overwrite directly + out of the zcrypt29 archive, do not use UnZip's freshen/updating + option; the dummy files may be newer than the real sources in + zcrypt29. ("unzip -o zcrypt29 -d /your/working/dir" will do the + Right Thing in most cases, although it may overwrite a newer WHERE + file under some circumstances.) + + (3) Read the main INSTALL document and compile normally! No makefile + changes are necessary on account of the zcrypt sources. You can + check that the version you just compiled has encryption or decryption + support enabled by typing "zip -v" or "unzip -v" and verifying that + the last "special compilation option" says encryption or decryption + is included. + +Encryption enables new "-e" and "-P password" options in Zip, and a new +"-P password" option in UnZip--see the normal Zip and UnZip documentation +for details. (Note that passing a plaintext password on the command line +is potentially much more insecure than being prompted for it interactively, +which is the default for UnZip and for Zip with "-e". Also note that the +interactive method allows UnZip to deal with archives that use different +passwords for different files.) Index: crypt.c =================================================================== RCS file: /var/cvs/Zip/crypt.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- crypt.c 8 Mar 2005 03:08:05 -0000 1.1.1.1 +++ crypt.c 8 Mar 2005 03:17:09 -0000 1.2 @@ -1,20 +1,577 @@ /* - Copyright (c) 1990-1999 Info-ZIP. All rights reserved. + Copyright (c) 1990-2000 Info-ZIP. All rights reserved. - See the accompanying file LICENSE, version 1999-Oct-05 or later + See the accompanying file LICENSE, version 2000-Apr-09 or later (the contents of which are also included in zip.h) for terms of use. - If, for some reason, both of these files are missing, the Info-ZIP license - also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html + If, for some reason, all these files are missing, the Info-ZIP license + also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html */ /* - crypt.c (dummy version) by Info-ZIP. Last revised: 15 Aug 98 + crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h] - This is a non-functional version of Info-ZIP's crypt.c encryption/ - decryption code for Zip, ZipCloak, UnZip and fUnZip. This file is - not copyrighted and may be distributed freely. :-) See the "WHERE" - file for sites from which to obtain the full encryption/decryption - sources (zcrypt28.zip or later). + The encryption/decryption parts of this source code (as opposed to the + non-echoing password parts) were originally written in Europe. The + whole source package can be freely distributed, including from the USA. + (Prior to January 2000, re-export from the US was a violation of US law.) */ +/* + This encryption code is a direct transcription of the algorithm from + Roger Schlafly, described by Phil Katz in the file appnote.txt. This + file (appnote.txt) is distributed with the PKZIP program (even in the + version without encryption capabilities). + */ + +#define ZCRYPT_INTERNAL +#include "zip.h" +#include "crypt.h" +#include "ttyio.h" + +#if CRYPT + +#ifndef FALSE +# define FALSE 0 +#endif + +#ifdef ZIP + /* For the encoding task used in Zip (and ZipCloak), we want to initialize + the crypt algorithm with some reasonably unpredictable bytes, see + the crypthead() function. The standard rand() library function is + used to supply these `random' bytes, which in turn is initialized by + a srand() call. The srand() function takes an "unsigned" (at least 16bit) + seed value as argument to determine the starting point of the rand() + pseudo-random number generator. + This seed number is constructed as "Seed = Seed1 .XOR. Seed2" with + Seed1 supplied by the current time (= "(unsigned)time()") and Seed2 + as some (hopefully) nondeterministic bitmask. On many (most) systems, + we use some "process specific" number, as the PID or something similar, + but when nothing unpredictable is available, a fixed number may be + sufficient. + NOTE: + 1.) This implementation requires the availability of the following + standard UNIX C runtime library functions: time(), rand(), srand(). + On systems where some of them are missing, the environment that + incorporates the crypt routines must supply suitable replacement + functions. + 2.) It is a very bad idea to use a second call to time() to set the + "Seed2" number! In this case, both "Seed1" and "Seed2" would be + (almost) identical, resulting in a (mostly) "zero" constant seed + number passed to srand(). + + The implementation environment defined in the "zip.h" header should + supply a reasonable definition for ZCR_SEED2 (an unsigned number; for + most implementations of rand() and srand(), only the lower 16 bits are + significant!). An example that works on many systems would be + "#define ZCR_SEED2 (unsigned)getpid()". + The default definition for ZCR_SEED2 supplied below should be regarded + as a fallback to allow successful compilation in "beta state" + environments. + */ +# include /* time() function supplies first part of crypt seed */ + /* "last resort" source for second part of crypt seed pattern */ +# ifndef ZCR_SEED2 +# define ZCR_SEED2 (unsigned)3141592654L /* use PI as default pattern */ +# endif +# ifdef GLOBAL /* used in Amiga system headers, maybe others too */ +# undef GLOBAL +# endif +# define GLOBAL(g) g +#else /* !ZIP */ +# define GLOBAL(g) G.g +#endif /* ?ZIP */ + + +#ifdef UNZIP + /* char *key = (char *)NULL; moved to globals.h */ +# ifndef FUNZIP + local int testp OF((__GPRO__ ZCONST uch *h)); + local int testkey OF((__GPRO__ ZCONST uch *h, ZCONST char *key)); +# endif +#endif /* UNZIP */ + +#ifndef UNZIP /* moved to globals.h for UnZip */ + local ulg keys[3]; /* keys defining the pseudo-random sequence */ +#endif /* !UNZIP */ + +#ifndef Trace +# ifdef CRYPT_DEBUG +# define Trace(x) fprintf x +# else +# define Trace(x) +# endif +#endif + +#ifndef CRC_32_TAB +# define CRC_32_TAB crc_32_tab +#endif + +#define CRC32(c, b) (CRC_32_TAB[((int)(c) ^ (b)) & 0xff] ^ ((c) >> 8)) + +/*********************************************************************** + * Return the next byte in the pseudo-random sequence + */ +int decrypt_byte(__G) + __GDEF +{ + unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an + * unpredictable manner on 16-bit systems; not a problem + * with any known compiler so far, though */ + + temp = ((unsigned)GLOBAL(keys[2]) & 0xffff) | 2; + return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); +} + +/*********************************************************************** + * Update the encryption keys with the next byte of plain text + */ +int update_keys(__G__ c) + __GDEF + int c; /* byte of plain text */ +{ + GLOBAL(keys[0]) = CRC32(GLOBAL(keys[0]), c); + GLOBAL(keys[1]) += GLOBAL(keys[0]) & 0xff; + GLOBAL(keys[1]) = GLOBAL(keys[1]) * 134775813L + 1; + { + register int keyshift = (int)(GLOBAL(keys[1]) >> 24); + GLOBAL(keys[2]) = CRC32(GLOBAL(keys[2]), keyshift); + } + return c; +} + + +/*********************************************************************** + * Initialize the encryption keys and the random header according to + * the given password. + */ +void init_keys(__G__ passwd) + __GDEF + ZCONST char *passwd; /* password string with which to modify keys */ +{ + GLOBAL(keys[0]) = 305419896L; + GLOBAL(keys[1]) = 591751049L; + GLOBAL(keys[2]) = 878082192L; + while (*passwd != '\0') { + update_keys(__G__ (int)*passwd); + passwd++; + } +} + + +#ifdef ZIP + +/*********************************************************************** + * Write encryption header to file zfile using the password passwd + * and the cyclic redundancy check crc. + */ +void crypthead(passwd, crc, zfile) + ZCONST char *passwd; /* password string */ + ulg crc; /* crc of file being encrypted */ + FILE *zfile; /* where to write header */ +{ + int n; /* index in random header */ + int t; /* temporary */ + int c; /* random byte */ + int ztemp; /* temporary for zencoded value */ + uch header[RAND_HEAD_LEN-2]; /* random header */ + static unsigned calls = 0; /* ensure different random header each time */ + + /* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the + * output of rand() to get less predictability, since rand() is + * often poorly implemented. + */ + if (++calls == 1) { + srand((unsigned)time(NULL) ^ ZCR_SEED2); + } + init_keys(passwd); + for (n = 0; n < RAND_HEAD_LEN-2; n++) { + c = (rand() >> 7) & 0xff; + header[n] = (uch)zencode(c, t); + } + /* Encrypt random header (last two bytes is high word of crc) */ + init_keys(passwd); + for (n = 0; n < RAND_HEAD_LEN-2; n++) { + ztemp = zencode(header[n], t); + putc(ztemp, zfile); + } + ztemp = zencode((int)(crc >> 16) & 0xff, t); + putc(ztemp, zfile); + ztemp = zencode((int)(crc >> 24) & 0xff, t); + putc(ztemp, zfile); +} + + +#ifdef UTIL + +/*********************************************************************** + * Encrypt the zip entry described by z from file source to file dest + * using the password passwd. Return an error code in the ZE_ class. + */ +int zipcloak(z, source, dest, passwd) + struct zlist far *z; /* zip entry to encrypt */ + FILE *source, *dest; /* source and destination files */ + ZCONST char *passwd; /* password string */ +{ + int c; /* input byte */ + int res; /* result code */ + ulg n; /* holds offset and counts size */ + ush flag; /* previous flags */ + int t; /* temporary */ + int ztemp; /* temporary storage for zencode value */ + + /* Set encrypted bit, clear extended local header bit and write local + header to output file */ + if ((n = (ulg)ftell(dest)) == (ulg)-1L) return ZE_TEMP; + z->off = n; + flag = z->flg; + z->flg |= 1, z->flg &= ~8; + z->lflg |= 1, z->lflg &= ~8; + z->siz += RAND_HEAD_LEN; + if ((res = putlocal(z, dest)) != ZE_OK) return res; + + /* Initialize keys with password and write random header */ + crypthead(passwd, z->crc, dest); + + /* Skip local header in input file */ + if (fseek(source, (long)(4 + LOCHEAD + (ulg)z->nam + (ulg)z->ext), + SEEK_CUR)) { + return ferror(source) ? ZE_READ : ZE_EOF; + } + + /* Encrypt data */ + for (n = z->siz - RAND_HEAD_LEN; n; n--) { + if ((c = getc(source)) == EOF) { + return ferror(source) ? ZE_READ : ZE_EOF; + } + ztemp = zencode(c, t); + putc(ztemp, dest); + } + /* Skip extended local header in input file if there is one */ + if ((flag & 8) != 0 && fseek(source, 16L, SEEK_CUR)) { + return ferror(source) ? ZE_READ : ZE_EOF; + } + if (fflush(dest) == EOF) return ZE_TEMP; + return ZE_OK; +} + +/*********************************************************************** + * Decrypt the zip entry described by z from file source to file dest + * using the password passwd. Return an error code in the ZE_ class. + */ +int zipbare(z, source, dest, passwd) + struct zlist far *z; /* zip entry to encrypt */ + FILE *source, *dest; /* source and destination files */ + ZCONST char *passwd; /* password string */ +{ + int c0, c1; /* last two input bytes */ + ulg offset; /* used for file offsets */ + ulg size; /* size of input data */ + int r; /* size of encryption header */ + int res; /* return code */ + ush flag; /* previous flags */ + + /* Save position and skip local header in input file */ + if ((offset = (ulg)ftell(source)) == (ulg)-1L || + fseek(source, (long)(4 + LOCHEAD + (ulg)z->nam + (ulg)z->ext), + SEEK_CUR)) { + return ferror(source) ? ZE_READ : ZE_EOF; + } + /* Initialize keys with password */ + init_keys(passwd); + + /* Decrypt encryption header, save last two bytes */ + c1 = 0; + for (r = RAND_HEAD_LEN; r; r--) { + c0 = c1; + if ((c1 = getc(source)) == EOF) { + return ferror(source) ? ZE_READ : ZE_EOF; + } + Trace((stdout, " (%02x)", c1)); + zdecode(c1); + Trace((stdout, " %02x", c1)); + } + Trace((stdout, "\n")); + + /* If last two bytes of header don't match crc (or file time in the + * case of an extended local header), back up and just copy. For + * pkzip 2.0, the check has been reduced to one byte only. + */ +#ifdef ZIP10 + if ((ush)(c0 | (c1<<8)) != + (z->flg & 8 ? (ush) z->tim & 0xffff : (ush)(z->crc >> 16))) { +#else + c0++; /* avoid warning on unused variable */ + if ((ush)c1 != (z->flg & 8 ? (ush) z->tim >> 8 : (ush)(z->crc >> 24))) { +#endif + if (fseek(source, offset, SEEK_SET)) { + return ferror(source) ? ZE_READ : ZE_EOF; + } + if ((res = zipcopy(z, source, dest)) != ZE_OK) return res; + return ZE_MISS; + } + + /* Clear encrypted bit and local header bit, and write local header to + output file */ + if ((offset = (ulg)ftell(dest)) == (ulg)-1L) return ZE_TEMP; + z->off = offset; + flag = z->flg; + z->flg &= ~9; + z->lflg &= ~9; + z->siz -= RAND_HEAD_LEN; + if ((res = putlocal(z, dest)) != ZE_OK) return res; + + /* Decrypt data */ + for (size = z->siz; size; size--) { + if ((c1 = getc(source)) == EOF) { + return ferror(source) ? ZE_READ : ZE_EOF; + } + zdecode(c1); + putc(c1, dest); + } + /* Skip extended local header in input file if there is one */ + if ((flag & 8) != 0 && fseek(source, 16L, SEEK_CUR)) { + return ferror(source) ? ZE_READ : ZE_EOF; + } + if (fflush(dest) == EOF) return ZE_TEMP; + + return ZE_OK; +} + + +#else /* !UTIL */ + +/*********************************************************************** + * If requested, encrypt the data in buf, and in any case call fwrite() + * with the arguments to zfwrite(). Return what fwrite() returns. + */ +unsigned zfwrite(buf, item_size, nb, f) + zvoid *buf; /* data buffer */ + extent item_size; /* size of each item in bytes */ + extent nb; /* number of items */ + FILE *f; /* file to write to */ +{ + int t; /* temporary */ + + if (key != (char *)NULL) { /* key is the global password pointer */ + ulg size; /* buffer size */ + char *p = (char*)buf; /* steps through buffer */ + + /* Encrypt data in buffer */ + for (size = item_size*(ulg)nb; size != 0; p++, size--) { + *p = (char)zencode(*p, t); + } + } + /* Write the buffer out */ + return fwrite(buf, item_size, nb, f); +} + +#endif /* ?UTIL */ +#endif /* ZIP */ + + +#if (defined(UNZIP) && !defined(FUNZIP)) + +/*********************************************************************** + * Get the password and set up keys for current zipfile member. + * Return PK_ class error. + */ +int decrypt(__G__ passwrd) + __GDEF + ZCONST char *passwrd; +{ + ush b; + int n, r; + uch h[RAND_HEAD_LEN]; + + Trace((stdout, "\n[incnt = %d]: ", GLOBAL(incnt))); + + /* get header once (turn off "encrypted" flag temporarily so we don't + * try to decrypt the same data twice) */ + GLOBAL(pInfo->encrypted) = FALSE; + defer_leftover_input(__G); + for (n = 0; n < RAND_HEAD_LEN; n++) { + b = NEXTBYTE; + h[n] = (uch)b; + Trace((stdout, " (%02x)", h[n])); + } + undefer_input(__G); + GLOBAL(pInfo->encrypted) = TRUE; + + if (GLOBAL(newzip)) { /* this is first encrypted member in this zipfile */ + GLOBAL(newzip) = FALSE; + if (passwrd != (char *)NULL) { /* user gave password on command line */ + if (!GLOBAL(key)) { + if ((GLOBAL(key) = (char *)malloc(strlen(passwrd)+1)) == + (char *)NULL) + return PK_MEM2; + strcpy(GLOBAL(key), passwrd); + GLOBAL(nopwd) = TRUE; /* inhibit password prompting! */ + } + } else if (GLOBAL(key)) { /* get rid of previous zipfile's key */ + free(GLOBAL(key)); + GLOBAL(key) = (char *)NULL; + } + } + + /* if have key already, test it; else allocate memory for it */ + if (GLOBAL(key)) { + if (!testp(__G__ h)) + return PK_COOL; /* existing password OK (else prompt for new) */ + else if (GLOBAL(nopwd)) + return PK_WARN; /* user indicated no more prompting */ + } else if ((GLOBAL(key) = (char *)malloc(IZ_PWLEN+1)) == (char *)NULL) + return PK_MEM2; + + /* try a few keys */ + n = 0; + do { + r = (*G.decr_passwd)((zvoid *)&G, &n, GLOBAL(key), IZ_PWLEN+1, + GLOBAL(zipfn), GLOBAL(filename)); + if (r == IZ_PW_ERROR) { /* internal error in fetch of PW */ + free (GLOBAL(key)); + GLOBAL(key) = NULL; + return PK_MEM2; + } + if (r != IZ_PW_ENTERED) { /* user replied "skip" or "skip all" */ + *GLOBAL(key) = '\0'; /* We try the NIL password, ... */ + n = 0; /* and cancel fetch for this item. */ + } + if (!testp(__G__ h)) + return PK_COOL; + if (r == IZ_PW_CANCELALL) /* User replied "Skip all" */ + GLOBAL(nopwd) = TRUE; /* inhibit any further PW prompt! */ + } while (n > 0); + + return PK_WARN; + +} /* end function decrypt() */ + + + +/*********************************************************************** + * Test the password. Return -1 if bad, 0 if OK. + */ +local int testp(__G__ h) + __GDEF + ZCONST uch *h; +{ + int r; + char *key_translated; + + /* On systems with "obscure" native character coding (e.g., EBCDIC), + * the first test translates the password to the "main standard" + * character coding. */ + +#ifdef STR_TO_CP1 + /* allocate buffer for translated password */ + if ((key_translated = malloc(strlen(GLOBAL(key)) + 1)) == (char *)NULL) + return -1; + /* first try, test password translated "standard" charset */ + r = testkey(__G__ h, STR_TO_CP1(key_translated, GLOBAL(key))); +#else /* !STR_TO_CP1 */ + /* first try, test password as supplied on the extractor's host */ + r = testkey(__G__ h, GLOBAL(key)); +#endif /* ?STR_TO_CP1 */ + +#ifdef STR_TO_CP2 + if (r != 0) { +#ifndef STR_TO_CP1 + /* now prepare for second (and maybe third) test with translated pwd */ + if ((key_translated = malloc(strlen(GLOBAL(key)) + 1)) == (char *)NULL) + return -1; +#endif + /* second try, password translated to alternate ("standard") charset */ + r = testkey(__G__ h, STR_TO_CP2(key_translated, GLOBAL(key))); +#ifdef STR_TO_CP3 + if (r != 0) + /* third try, password translated to another "standard" charset */ + r = testkey(__G__ h, STR_TO_CP3(key_translated, GLOBAL(key))); +#endif +#ifndef STR_TO_CP1 + free(key_translated); +#endif + } +#endif /* STR_TO_CP2 */ + +#ifdef STR_TO_CP1 + free(key_translated); + if (r != 0) { + /* last resort, test password as supplied on the extractor's host */ + r = testkey(__G__ h, GLOBAL(key)); + } +#endif /* STR_TO_CP1 */ + + return r; + +} /* end function testp() */ + + +local int testkey(__G__ h, key) + __GDEF + ZCONST uch *h; /* decrypted header */ + ZCONST char *key; /* decryption password to test */ +{ + ush b; +#ifdef ZIP10 + ush c; +#endif + int n; + uch *p; + uch hh[RAND_HEAD_LEN]; /* decrypted header */ + + /* set keys and save the encrypted header */ + init_keys(__G__ key); + memcpy(hh, h, RAND_HEAD_LEN); + + /* check password */ + for (n = 0; n < RAND_HEAD_LEN; n++) { + zdecode(hh[n]); + Trace((stdout, " %02x", hh[n])); + } + + Trace((stdout, + "\n lrec.crc= %08lx crec.crc= %08lx pInfo->ExtLocHdr= %s\n", + GLOBAL(lrec.crc32), GLOBAL(pInfo->crc), + GLOBAL(pInfo->ExtLocHdr) ? "true":"false")); + Trace((stdout, " incnt = %d unzip offset into zipfile = %ld\n", + GLOBAL(incnt), + GLOBAL(cur_zipfile_bufstart)+(GLOBAL(inptr)-GLOBAL(inbuf)))); + + /* same test as in zipbare(): */ + +#ifdef ZIP10 /* check two bytes */ + c = hh[RAND_HEAD_LEN-2], b = hh[RAND_HEAD_LEN-1]; + Trace((stdout, + " (c | (b<<8)) = %04x (crc >> 16) = %04x lrec.time = %04x\n", + (ush)(c | (b<<8)), (ush)(GLOBAL(lrec.crc32) >> 16), + ((ush)GLOBAL(lrec.last_mod_dos_datetime) & 0xffff)))); + if ((ush)(c | (b<<8)) != (GLOBAL(pInfo->ExtLocHdr) ? + ((ush)GLOBAL(lrec.last_mod_dos_datetime) & 0xffff) : + (ush)(GLOBAL(lrec.crc32) >> 16))) + return -1; /* bad */ +#else + b = hh[RAND_HEAD_LEN-1]; + Trace((stdout, " b = %02x (crc >> 24) = %02x (lrec.time >> 8) = %02x\n", + b, (ush)(GLOBAL(lrec.crc32) >> 24), + ((ush)GLOBAL(lrec.last_mod_dos_datetime) >> 8) & 0xff)); + if (b != (GLOBAL(pInfo->ExtLocHdr) ? + ((ush)GLOBAL(lrec.last_mod_dos_datetime) >> 8) & 0xff : + (ush)(GLOBAL(lrec.crc32) >> 24))) + return -1; /* bad */ +#endif + /* password OK: decrypt current buffer contents before leaving */ + for (n = (long)GLOBAL(incnt) > GLOBAL(csize) ? + (int)GLOBAL(csize) : GLOBAL(incnt), + p = GLOBAL(inptr); n--; p++) + zdecode(*p); + return 0; /* OK */ + +} /* end function testkey() */ + +#endif /* UNZIP && !FUNZIP */ + +#else /* !CRYPT */ + /* something "externally visible" to shut up compiler/linker warnings */ int zcr_dummy; + +#endif /* ?CRYPT */ Index: crypt.h =================================================================== RCS file: /var/cvs/Zip/crypt.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- crypt.h 8 Mar 2005 03:08:05 -0000 1.1.1.1 +++ crypt.h 8 Mar 2005 03:17:09 -0000 1.2 @@ -1,19 +1,13 @@ /* - Copyright (c) 1990-1999 Info-ZIP. All rights reserved. + Copyright (c) 1990-2000 Info-ZIP. All rights reserved. - See the accompanying file LICENSE, version 1999-Oct-05 or later + See the accompanying file LICENSE, version 2000-Apr-09 or later (the contents of which are also included in zip.h) for terms of use. - If, for some reason, both of these files are missing, the Info-ZIP license - also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html + If, for some reason, all these files are missing, the Info-ZIP license + also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html */ /* - crypt.h (dummy version) by Info-ZIP. Last revised: 15 Aug 98 - - This is a non-functional version of Info-ZIP's crypt.h encryption/ - decryption header file for Zip, ZipCloak, UnZip and fUnZip. This - file is not copyrighted and may be distributed without restriction. - See the "WHERE" file for sites from which to obtain the full crypt - sources (zcrypt28.zip or later). + crypt.h (full version) by Info-ZIP. Last revised: [see CR_VERSION_DATE] */ #ifndef __crypt_h /* don't include more than once */ @@ -22,11 +16,131 @@ #ifdef CRYPT # undef CRYPT #endif -#define CRYPT 0 /* dummy version */ + +#if !defined(NO_CRYPT) +# define CRYPT 1 /* full version */ +#else +# define CRYPT 0 /* dummy version */ +#endif + +#if CRYPT +/* full version */ + +#ifdef CR_BETA +# undef CR_BETA /* this is not a beta release */ +#endif + +#define CR_MAJORVER 2 +#define CR_MINORVER 9 +#ifdef CR_BETA +# define CR_BETA_VER "a BETA" +# define CR_VERSION_DATE "9 April 2000" /* last real code change */ +#else +# define CR_BETA_VER "" +# define CR_VERSION_DATE "22 April 2000" /* last public release date */ +# define CR_RELEASE +#endif + +#ifndef __G /* UnZip only, for now (DLL stuff) */ +# define __G +# define __G__ +# define __GDEF +# define __GPRO void +# define __GPRO__ +#endif + +#if defined(MSDOS) || defined(OS2) || defined(WIN32) +# ifndef DOS_OS2_W32 +# define DOS_OS2_W32 +# endif +#endif + +#if defined(DOS_OS2_W32) || defined(__human68k__) +# ifndef DOS_H68_OS2_W32 +# define DOS_H68_OS2_W32 +# endif +#endif + +#if defined(VM_CMS) || defined(MVS) +# ifndef CMS_MVS +# define CMS_MVS +# endif +#endif + +/* To allow combining of Zip and UnZip static libraries in a single binary, + * the Zip and UnZip versions of the crypt core functions have to be named + * differently. + */ +#ifdef ZIP +# ifdef REALLY_SHORT_SYMS +# define decrypt_byte zdcrby +# else +# define decrypt_byte zp_decrypt_byte +# endif +# define update_keys zp_update_keys +# define init_keys zp_init_keys +#else /* !ZIP */ +# ifdef REALLY_SHORT_SYMS +# define decrypt_byte dcrbyt +# endif +#endif /* ?ZIP */ + +#define IZ_PWLEN 80 /* input buffer size for reading encryption key */ +#ifndef PWLEN /* for compatibility with previous zcrypt release... */ +# define PWLEN IZ_PWLEN +#endif +#define RAND_HEAD_LEN 12 /* length of encryption random header */ + +/* the crc_32_tab array has to be provided externally for the crypt calculus */ +#ifndef CRC_32_TAB /* UnZip provides this in globals.h */ +# if (!defined(USE_ZLIB) || defined(USE_OWN_CRCTAB)) + extern ZCONST ulg near *crc_32_tab; +# else + extern ZCONST ulg Far *crc_32_tab; +# endif +#endif /* !CRC_32_TAB */ + +/* encode byte c, using temp t. Warning: c must not have side effects. */ +#define zencode(c,t) (t=decrypt_byte(__G), update_keys(c), t^(c)) + +/* decode byte c in place */ +#define zdecode(c) update_keys(__G__ c ^= decrypt_byte(__G)) + +int decrypt_byte OF((__GPRO)); +int update_keys OF((__GPRO__ int c)); +void init_keys OF((__GPRO__ ZCONST char *passwd)); + +#ifdef ZIP + void crypthead OF((ZCONST char *, ulg, FILE *)); +# ifdef UTIL + int zipcloak OF((struct zlist far *, FILE *, FILE *, ZCONST char *)); + int zipbare OF((struct zlist far *, FILE *, FILE *, ZCONST char *)); +# else + unsigned zfwrite OF((zvoid *, extent, extent, FILE *)); + extern char *key; +# endif +#endif /* ZIP */ + +#if (defined(UNZIP) && !defined(FUNZIP)) + int decrypt OF((__GPRO__ ZCONST char *passwrd)); +#endif + +#ifdef FUNZIP + extern int encrypted; +# ifdef NEXTBYTE +# undef NEXTBYTE +# endif +# define NEXTBYTE \ + (encrypted? update_keys(__G__ getc(G.in)^decrypt_byte(__G)) : getc(G.in)) +#endif /* FUNZIP */ + +#else /* !CRYPT */ +/* dummy version */ #define zencode #define zdecode #define zfwrite fwrite +#endif /* ?CRYPT */ #endif /* !__crypt_h */ Index: fileio.c =================================================================== RCS file: /var/cvs/Zip/fileio.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- fileio.c 8 Mar 2005 03:08:05 -0000 1.1.1.1 +++ fileio.c 8 Mar 2005 03:46:00 -0000 1.2 @@ -339,14 +339,14 @@ /* A null string is a legitimate external directory name in AmigaDOS; also, * a command like "zip -r zipfile FOO:" produces an empty internal name. */ -# ifndef RISCOS +#if (!defined(RISCOS) || defined(UNIXLIB)) /* If extensions needs to be swapped, we will have empty directory names instead of the original directory. For example, zipping 'c.', 'c.main' should zip only 'main.c' while 'c.' will be converted to '\0' by ex2in. */ if (pathput && !recurse) error("empty name without -j or -r"); -# endif /* !RISCOS */ +# endif /* !RISCOS || UNIXLIB */ #endif /* !AMIGA */ free((zvoid *)iname); return ZE_OK; @@ -830,8 +830,8 @@ } # else /* !AMIGA */ # ifdef RISCOS - if (lastchar(t) != '.') - strcat(t, "."); + if (lastchar(t) != PATHSEP) + strcat(t, PATHSEPSTR); # else /* !RISCOS */ # ifdef QDOS if (lastchar(t) != '_') Index: globals.c =================================================================== RCS file: /var/cvs/Zip/globals.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- globals.c 8 Mar 2005 03:08:05 -0000 1.1.1.1 +++ globals.c 8 Mar 2005 03:46:00 -0000 1.2 @@ -26,7 +26,7 @@ int recurse = 0; /* 1=recurse into directories encountered */ int dispose = 0; /* 1=remove files after put in zip file */ int pathput = 1; /* 1=store path with name */ -#ifdef RISCOS +#if defined(RISCOS) && !defined(UNIXLIB) int scanimage = 1; /* 1=scan through image files */ #endif int method = BEST; /* one of BEST, DEFLATE (only), or STORE (only) */ Index: revision.h =================================================================== RCS file: /var/cvs/Zip/revision.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- revision.h 8 Mar 2005 03:08:05 -0000 1.1.1.1 +++ revision.h 8 Mar 2005 06:13:08 -0000 1.2 @@ -35,7 +35,11 @@ #ifndef DEFCPYRT /* copyright[] gets defined only once ! */ extern ZCONST char *copyright[2]; /* keep array sizes in sync with number */ extern ZCONST char *swlicense[40]; /* of text line in definition below !! */ +#ifdef RISCOS +extern ZCONST char *versinfolines[6]; +#else extern ZCONST char *versinfolines[7]; +#endif #else /* DEFCPYRT */ @@ -50,11 +54,18 @@ ZCONST char *versinfolines[] = { "This is %s %s (%s), by Info-ZIP.", +#ifdef RISCOS +"RISC OS Packaging Project distribution maintained by Graham Shaw.", +"For bug reports, go to http://www.riscpkg.org/bugs.html.", +"", +"Original sources maintained by Onno van der Linden.", +#else "Currently maintained by Onno van der Linden. Please send bug reports to", "the authors at Zip-Bugs@lists.wku.edu; see README for details.", "", "Latest sources and executables are at ftp://ftp.cdrom.com/pub/infozip, as of", "above date; see http://www.cdrom.com/pub/infozip/Zip.html for other sites.", +#endif "" }; Index: util.c =================================================================== RCS file: /var/cvs/Zip/util.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- util.c 8 Mar 2005 03:08:05 -0000 1.1.1.1 +++ util.c 8 Mar 2005 03:46:00 -0000 1.2 @@ -61,7 +61,7 @@ #ifdef VMS else if (*p == '%' || *p == '*') #else /* !VMS */ -# ifdef RISCOS +# if defined(RISCOS) && !defined(UNIXLIB) /* RISC OS uses # as its single-character wildcard */ else if (*p == '#' || *p == '*' || *p == '[') # else /* !RISC OS */ @@ -94,7 +94,7 @@ #ifdef VMS if (c == '%') #else /* !VMS */ -# ifdef RISCOS +# if defined(RISCOS) && !defined(UNIXLIB) if (c == '#') # else /* !RISC OS */ if (c == '?') Index: zip.c =================================================================== RCS file: /var/cvs/Zip/zip.c,v retrieving revision 1.1.1.1 retrieving revision 1.3 diff -u -r1.1.1.1 -r1.3 --- zip.c 8 Mar 2005 03:08:05 -0000 1.1.1.1 +++ zip.c 8 Mar 2005 06:13:08 -0000 1.3 @@ -368,8 +368,12 @@ #ifdef VMS "Zip %s (%s). Usage: zip==\"$disk:[dir]zip.exe\"", #else +#ifdef RISCOS +"Zip %s (%s) (adapted for RISC OS Packaging Project). Usage:", +#else "Zip %s (%s). Usage:", #endif +#endif #ifdef MACOS "zip [-options] [-b fm] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]", " The default action is to add or replace zipfile entries from list.", @@ -900,7 +904,7 @@ } #endif -#ifdef RISCOS +#if defined(RISCOS) && !defined(UNIXLIB) set_prefix(); #endif @@ -1171,7 +1175,11 @@ #ifdef RISCOS case 'I': /* Don't scan through Image files */ +#ifdef UNIXLIB + __feature_imagefs_is_file = 1; +#else scanimage = 0; +#endif break; #endif #ifdef MACOS @@ -1611,7 +1619,7 @@ if (*p == ':') p++; #else -#ifdef RISCOS +#if defined(RISCOS) && !defined(UNIXLIB) if (tempath == NULL && (p = MBSRCHR(zipfile, '.')) != NULL) { #else @@ -1758,6 +1766,11 @@ */ if (strcmp(zipfile, "-")) { +#if defined(RISCOS) && defined(UNIXLIB) + int imagefs_is_file = __feature_imagefs_is_file; + __feature_imagefs_is_file=1; +#endif + if (tempdir && zfiles == NULL && zipbeg == 0) { a = 0; } else { @@ -1772,6 +1785,10 @@ if (zfiles == NULL && zipbeg == 0) destroy(zipfile); } + +#if defined(RISCOS) && defined(UNIXLIB) + __feature_imagefs_is_file=imagefs_is_file; +#endif } else a = 0; @@ -1812,6 +1829,11 @@ } else if (d) /* d true if just appending (-g) */ { +#if defined(RISCOS) && defined(UNIXLIB) + int imagefs_is_file = __feature_imagefs_is_file; + __feature_imagefs_is_file=1; +#endif + if ((y = fopen(zipfile, FOPM)) == NULL) { ZIPERR(ZE_NAME, zipfile); } @@ -1821,9 +1843,17 @@ ZIPERR(ferror(y) ? ZE_READ : ZE_EOF, zipfile); } tempzn = cenbeg; + +#if defined(RISCOS) && defined(UNIXLIB) + __feature_imagefs_is_file=imagefs_is_file; +#endif } else { +#if defined(RISCOS) && defined(UNIXLIB) + int imagefs_is_file = __feature_imagefs_is_file; + __feature_imagefs_is_file=1; +#endif if ((zfiles != NULL || zipbeg) && (x = fopen(zipfile, FOPR_EX)) == NULL) { ZIPERR(ZE_NAME, zipfile); } @@ -1833,6 +1863,9 @@ if ((tempzf = y = fopen(tempzip, FOPW_TMP)) == NULL) { ZIPERR(ZE_TEMP, tempzip); } +#if defined(RISCOS) && defined(UNIXLIB) + __feature_imagefs_is_file=imagefs_is_file; +#endif } #if (!defined(VMS) && !defined(CMS_MVS)) @@ -2053,7 +2086,7 @@ #endif { if (comment_stream == NULL) { -#ifndef RISCOS +#if !defined(RISCOS) || defined(UNIXLIB) comment_stream = (FILE*)fdopen(fileno(stderr), "r"); #else comment_stream = stderr; @@ -2121,7 +2154,7 @@ { #ifndef WINDLL if (comment_stream == NULL) { -#ifndef RISCOS +#if !defined(RISCOS) || defined(UNIXLIB) comment_stream = (FILE*)fdopen(fileno(stderr), "r"); #else comment_stream = stderr; @@ -2244,6 +2277,9 @@ /* Replace old zip file with new zip file, leaving only the new one */ if (strcmp(zipfile, "-") && !d) { + int imagefs_is_file=__feature_imagefs_is_file; + __feature_imagefs_is_file=1; + diag("replacing old zip file with new zip file"); if ((r = replace(zipfile, tempzip)) != ZE_OK) { @@ -2253,6 +2289,8 @@ ZIPERR(r, "was replacing the original zip file"); } free((zvoid *)tempzip); + + __feature_imagefs_is_file=imagefs_is_file; } tempzip = NULL; if (a && strcmp(zipfile, "-")) { Index: zip.h =================================================================== RCS file: /var/cvs/Zip/zip.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- zip.h 8 Mar 2005 03:08:05 -0000 1.1.1.1 +++ zip.h 8 Mar 2005 03:46:00 -0000 1.2 @@ -245,7 +245,7 @@ extern int dispose; /* Remove files after put in zip file */ extern int pathput; /* Store path with name */ -#ifdef RISCOS +#if defined(RISCOS) && !defined(UNIXLIB) extern int scanimage; /* Scan through image files */ #endif Index: zipcloak.c =================================================================== RCS file: /var/cvs/Zip/zipcloak.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- zipcloak.c 8 Mar 2005 03:08:05 -0000 1.1.1.1 +++ zipcloak.c 8 Mar 2005 06:13:08 -0000 1.2 @@ -117,7 +117,11 @@ static ZCONST char *help_info[] = { "", +#ifdef RISCOS +"ZipCloak %s (%s) (adapted for RISC OS Packaging Project)", +#else "ZipCloak %s (%s)", +#endif #ifdef VM_CMS "Usage: zipcloak [-d] [-b fm] zipfile", #else Index: zipfile.c =================================================================== RCS file: /var/cvs/Zip/zipfile.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- zipfile.c 8 Mar 2005 03:08:05 -0000 1.1.1.1 +++ zipfile.c 8 Mar 2005 03:46:00 -0000 1.2 @@ -1053,8 +1053,16 @@ } readable = ((f = fopen(zipfile, FOPR)) != NULL); #else /* !VMS */ +#if defined(RISCOS) && defined(UNIXLIB) + { + int imagefs_is_file=__feature_imagefs_is_file; + __feature_imagefs_is_file=1; +#endif readable = (zipfile != NULL && *zipfile && strcmp(zipfile, "-") && (f = fopen(zipfile, FOPR)) != NULL); +#if defined(RISCOS) && defined(UNIXLIB) + __feature_imagefs_is_file=imagefs_is_file; + } #endif /* ?VMS */ #ifdef MVS /* Very nasty special case for MVS. Just because the zipfile has been Index: zipnote.c =================================================================== RCS file: /var/cvs/Zip/zipnote.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- zipnote.c 8 Mar 2005 03:08:05 -0000 1.1.1.1 +++ zipnote.c 8 Mar 2005 06:13:08 -0000 1.2 @@ -115,7 +115,11 @@ /* help array */ static ZCONST char *text[] = { "", +#ifdef RISCOS +"ZipNote %s (%s) (adapted for RISC OS Packaging Project)", +#else "ZipNote %s (%s)", +#endif #ifdef VM_CMS "Usage: zipnote [-w] [-b fm] zipfile", #else Index: zipsplit.c =================================================================== RCS file: /var/cvs/Zip/zipsplit.c,v retrieving revision 1.1.1.1 retrieving revision 1.3 diff -u -r1.1.1.1 -r1.3 --- zipsplit.c 8 Mar 2005 03:08:05 -0000 1.1.1.1 +++ zipsplit.c 8 Mar 2005 06:13:08 -0000 1.3 @@ -25,7 +25,7 @@ #else /* !MSDOS */ # define NL 1 /* Number of bytes written for a \n */ #endif /* ?MSDOS */ -#ifdef RISCOS +#if defined(RISCOS) && !defined(UNIXLIB) # define INDEX "zipspl/idx" /* Name of index file */ # define TEMPL_FMT "%%0%dld" # define TEMPL_SIZ 13 @@ -199,14 +199,18 @@ /* help array */ static ZCONST char *text[] = { "", +#ifdef RISCOS +"ZipSplit %s (%s) (adapted for RISC OS Packaging Project)", +#else "ZipSplit %s (%s)", +#endif #ifdef VM_CMS "Usage: zipsplit [-tips] [-n size] [-r room] [-b fm] zipfile", #else "Usage: zipsplit [-tips] [-n size] [-r room] [-b path] zipfile", #endif " -t report how many files it will take, but don't make them", -#ifdef RISCOS +#if defined(RISCOS) && !defined(UNIXLIB) " -i make index (" INDEX ") and count its size against first zip file", #else " -i make index (zipsplit.idx) and count its size against first zip file", @@ -620,7 +624,7 @@ strcat(path, "/"); name = path + strlen(path); #else -# ifdef RISCOS +# if defined(RISCOS) && !defined(UNIXLIB) if (path[0] && path[strlen(path) - 1] != '.') strcat(path, "."); name = path + strlen(path); @@ -671,7 +675,7 @@ if (((q = strrchr(zipfile, '/')) != NULL) || ((q = strrchr(zipfile, ':'))) != NULL) #else -#ifdef RISCOS +#if defined(RISCOS) && !defined(UNIXLIB) if ((q = strrchr(zipfile, '.')) != NULL) #else #ifdef MVS Index: !Zip/!Boot,feb =================================================================== RCS file: !Zip/!Boot,feb diff -N !Zip/!Boot,feb --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ !Zip/!Boot,feb 8 Mar 2005 17:35:50 -0000 1.2 @@ -0,0 +1,11 @@ +| This file is part of the RISC OS Packaging Project distribution of Zip. +| Copyright © 2005 Graham Shaw. +| Distribution and use are subject to the Info-ZIP licence, a copy of which +| may be found in the file ".LICENSE". + +If ""="" Then Set Zip$Dir +If ""="" AND ""="" Then Set Alias$zip /.zip %%*0 +If ""="" AND ""="" Then Set Alias$zipnote /.zipnote %%*0 +If ""="" AND ""="" Then Set Alias$zipsplit /.zipsplit %%*0 +If ""="" AND ""="" Then Set Alias$zipcloak /.zipcloak %%*0 +IconSprites .!Sprites Index: !Zip/!Help,feb =================================================================== RCS file: !Zip/!Help,feb diff -N !Zip/!Help,feb --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ !Zip/!Help,feb 8 Mar 2005 07:29:30 -0000 1.1 @@ -0,0 +1,6 @@ +| This file is part of the RISC OS Packaging Project distribution of Zip. +| Copyright © 2005 Graham Shaw. +| Distribution and use are subject to the Info-ZIP licence, a copy of which +| may be found in the file ".LICENSE". + +Filer_Run .MANUAL Index: !Zip/!Run,feb =================================================================== RCS file: !Zip/!Run,feb diff -N !Zip/!Run,feb --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ !Zip/!Run,feb 8 Mar 2005 07:29:30 -0000 1.1 @@ -0,0 +1,11 @@ +| This file is part of the RISC OS Packaging Project distribution of Zip. +| Copyright © 2005 Graham Shaw. +| Distribution and use are subject to the Info-ZIP licence, a copy of which +| may be found in the file ".LICENSE". + +Set Zip$Dir +Set Alias$zip /.zip %%*0 +Set Alias$zipnote /.zipnote %%*0 +Set Alias$zipsplit /.zipsplit %%*0 +Set Alias$zipcloak /.zipcloak %%*0 +IconSprites .!Sprites Index: !Zip/!Sprites.uue =================================================================== RCS file: !Zip/!Sprites.uue diff -N !Zip/!Sprites.uue --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ !Zip/!Sprites.uue 8 Mar 2005 07:29:30 -0000 1.1 @@ -0,0 +1,20 @@ +begin 707 !Zip/!Sprites,ff9 +M`0```!````#D`@``U`(``"%Z:7````````````0````0``````````<````L +M````@`$```P````````P-$1$1$1$1$1$1$1$1````````#`T1``````````P +M1$1$````0T1$1$1$1$1$1`0``#!$1$0``````````````````````%,7`P`` +M``"`B(CP^("(^```````=3$%``````#P^``(@`"````````74P<``````(\/ +M``B`B/@``````#%U`0````#P^```"(``````````4Q<#`````("(B/#X@``` +M``````!U,04``````````````````````!=3!P```$-$1$1$1$1$1$0$```P +M1$1$````````,#1$`````````#!$1$0````````P-$1$1$1$1$1$1$1$1``` +M````````````````````,$0``````````````$-$1$1$1$1$1``````````` +M````0P0```````````````````````!#!````````````````````/#_____ +M______________\`````\/\`````````\/____________________\/``#P +M_____________________P\```#__P__________________#P```/__#___ +M______________\/````__\/_________________P\```#__P__________ +M________#P```/__#_________________\/````__\/________________ +M_P\```#__P__________________#P``\/_______P````#P_P````````#P +M________`````/#___________________\``````````````````/#_`/__ +M_P````````#___________\`____`````````/\/``````````#___\````` +0````_P\``````````/___P`` +` +end Index: !Zip/!Sprites22.uue =================================================================== RCS file: !Zip/!Sprites22.uue diff -N !Zip/!Sprites22.uue --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ !Zip/!Sprites22.uue 8 Mar 2005 07:29:30 -0000 1.1 @@ -0,0 +1,35 @@ +begin 505 !Zip/!Sprites22,ff9 +M`0```!````",!0``?`4``"%Z:7````````````0````A``````````<````L +M````U`(``!L``````````$-$1$1$1$1$1$1$1```````````0T1$1$1$1$1$ +M1$1$``````````!#!````````#!$1$0``````````$,$````````,$1$1``` +M`$-$1$1$1$1$1$1$!``P1$1$````0T1$1$1$1$1$1$0$`#!$1$0````````` +M`````````````%,7`P``````````````````````4Q<#`````("(B`"("("( +M^`````!U,04`````@(B(`(@(@(B(`````'4Q!0```````(\`@`"``(`````` +M%U,'````````B`"``(``@``````74P<``````(`(`(``@(B(`````#%U`0`` +M````B```@`"`B/@`````,74!`````(`(``"``(````````!3%P,`````@`\` +M`(``@````````%,7`P````"`B(@`B`B`````````=3$%`````("(B`"("(`` +M``````!U,04``````````````````````!=3!P`````````````````````` +M%U,'````0T1$1$1$1$1$1$0$`#!$1$0```!#1$1$1$1$1$1$1`0`,$1$1``` +M````````0P0````````P1$1$``````````!#!````````#!$1$0````````` +M`$-$1$1$1$1$1$1$1```````````0T1$1$1$1$1$1$1$```````````````` +M```````P1````````````````````````#!$```````````````````````` +M,$0``````````````#!$1$1$1$1$1```````````````,$1$1$1$1$1$```` +M```````````P1````````````````````````#!$```````````````````` +M````,$0`````````````````````____________________``````#_____ +M______________\``````/\/````````\/_______P``````_P\```````#P +M______________________\/`/#______________________P\`\/______ +M_P``````````````````__\/__________________\/``#__P__________ +M_________P\``/__#___________________#P``__\/________________ +M__\/``#__P___________________P\``/__#___________________#P`` +M__\/__________________\/``#__P___________________P\``/__#___ +M________________#P``__\/__________________\/``#__P__________ +M_________P\``/__#___________________#P``__\/____```````````` +M``````#__P___________________P\`\/______________________#P#P +M________``````#_#P```````/#_______\``````/\/````````\/______ +M_P``````____________________``````#___________________\````` +M`````````````/#_`/___P``````````````````\/\`____```````````` +M``````#P_P#___\`````````\/__________`/___P````````#P________ +M__\`____`````````/#_``````````#___\`````````\/\``````````/__ +5_P````````#P_P``````````____ +` +end Index: RiscPkg/Changes =================================================================== RCS file: RiscPkg/Changes diff -N RiscPkg/Changes --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ RiscPkg/Changes 10 Mar 2005 05:06:59 -0000 1.2 @@ -0,0 +1,9 @@ +This is the RISC OS Packaging Project distribution of Zip. + +User-visible differences between package version 2.3-0 and upstream +version 2.3: + +- Encryption sources added. +- Modified to support UNIX-style pathnames. +- Suffix list now obtained, in ascending order of priority, from + , or . Index: RiscPkg/Control =================================================================== RCS file: RiscPkg/Control diff -N RiscPkg/Control --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ RiscPkg/Control 8 Mar 2005 08:17:26 -0000 1.2 @@ -0,0 +1,19 @@ +Source: Zip +Section: File +Priority: Important +Licence: Free +Maintainer: Graham Shaw +Standards-Version: 0.1.0 +Version: 2.3-0 +Description: A compressor/archiver for creating and modifying zipfiles + This is the Info-ZIP file compressor and archiver program, Zip. It + produces files which are compatible with the PKWARE programs PKZIP and + PKUNZIP (however its command-line options are not fully compatible). + . + The commands provided by this package are zip, zipnote, zipsplit and + zipcloak. + . + This version supports encryption. It has been modified to support both + RISC OS- and UNIX-style pathnames using UnixLib. + +Package: Zip Index: RiscPkg/Copyright =================================================================== RCS file: RiscPkg/Copyright diff -N RiscPkg/Copyright --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ RiscPkg/Copyright 8 Mar 2005 08:27:57 -0000 1.2 @@ -0,0 +1,66 @@ +This is part of the RISC OS Packaging Project distribution of Zip. + +Zip was written by the Info-ZIP project (http://www.info-zip.org). + +The upstream sources were downloaded from the URLs: + +http://ftp.info-zip.org/pub/infozip/src/zip23.zip +http://ftp.info-zip.org/pub/infozip/src/zcrypt29.zip + +on 8th March 2005. There is a homepage at the URL: + +http://www.info-zip.org/Zip.html + +Zip is subject to the following licence (from the file LICENSE): + +== begin == +This is version 1999-Oct-05 of the Info-ZIP copyright and license. +The definitive version of this document should be available at +ftp://ftp.cdrom.com/pub/infozip/license.html indefinitely. + + +Copyright (c) 1990-1999 Info-ZIP. All rights reserved. + +For the purposes of this copyright and license, "Info-ZIP" is defined as +the following set of individuals: + + Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois, + Jean-loup Gailly, Hunter Goatley, Ian Gorman, Chris Herborth, Dirk Haase, + Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz, David Kirschbaum, + Johnny Lee, Onno van der Linden, Igor Mandrichenko, Steve P. Miller, + Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs, Kai Uwe Rommel, + Steve Salisbury, Dave Smith, Christian Spieler, Antoine Verheijen, + Paul von Behren, Rich Wales, Mike White + +This software is provided "as is," without warranty of any kind, express +or implied. In no event shall Info-ZIP or its contributors be held liable +for any direct, indirect, incidental, special or consequential damages +arising out of the use of or inability to use this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. Redistributions of source code must retain the above copyright notice, + definition, disclaimer, and this list of conditions. + + 2. Redistributions in binary form must reproduce the above copyright + notice, definition, disclaimer, and this list of conditions in + documentation and/or other materials provided with the distribution. + + 3. Altered versions--including, but not limited to, ports to new operating + systems, existing ports with new graphical interfaces, and dynamic, + shared, or static library versions--must be plainly marked as such + and must not be misrepresented as being the original source. Such + altered versions also must not be misrepresented as being Info-ZIP + releases--including, but not limited to, labeling of the altered + versions with the names "Info-ZIP" (or any variation thereof, including, + but not limited to, different capitalizations), "Pocket UnZip," "WiZ" + or "MacZip" without the explicit permission of Info-ZIP. Such altered + versions are further prohibited from misrepresentative use of the + Zip-Bugs or Info-ZIP e-mail addresses or of the Info-ZIP URL(s). + + 4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip," + "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its own source and + binary releases. +== end == Index: RiscPkg/Rules =================================================================== RCS file: RiscPkg/Rules diff -N RiscPkg/Rules --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ RiscPkg/Rules 8 Mar 2005 05:18:05 -0000 1.1 @@ -0,0 +1,97 @@ +VERSION = 2.3-0 +PACKAGES = Zip_$(VERSION) + +BIN = \ + zip \ + zipnote \ + zipsplit \ + zipcloak + +TEXT = \ + BUGS \ + CHANGES \ + LICENSE \ + MANUAL \ + README \ + README.CR \ + TODO \ + WHATSNEW \ + WHERE + +SPRITES = \ + !Zip/!Sprites \ + !Zip/!Sprites22 + +.PHONY: all +all: uudecode + make -f acorn/Makefile.riscpkg + rm -rf Temp + mkdir -p Temp/RiscPkg + cp RiscPkg/Copyright Temp/RiscPkg/ + cp RiscPkg/Changes Temp/RiscPkg/ + mkdir -p Temp/Apps/File/!Zip + cp -r !Zip Temp/Apps/File/ + cp $(BIN) $(TEXT) Temp/Apps/File/!Zip/ + + chmod -R 444 Temp/Apps + cp -R SysVars Temp/SysVars/ + cp -R Sprites Temp/Sprites/ + make -C Temp -f ../RiscPkg/Rules $(PACKAGES) + rm -rf Temp + +.PHONY: clean +clean: + rm -f $(addprefix RiscPkg/,$(PACKAGES)) + make -f acorn/Makefile.riscpkg clean + +.PHONY: distclean +distclean: uuencode + rm -f $(SPRITES) + rm -f $(addprefix RiscPkg/,$(PACKAGES)) + make -f acorn/Makefile.riscpkg distclean + +.PHONY: $(PACKAGES) +$(PACKAGES): %: + riscpkg-gencontrol $(firstword $(subst _, ,$@)) < ../RiscPkg/Control > RiscPkg/Control + rm -f ../RiscPkg/$@ + zip -r ../RiscPkg/$@ * -i@../RiscPkg/$(firstword $(subst _, ,$@)).inc + +# ---------------------------------------- +# $(uu) == encode +# ---------------------------------------- + +.PHONY: uuencode + +ifeq (encode,$(uu)) + +uuencode: $(addsuffix .uue,$(SPRITES)) + +%.uue: % + uuencode $^,ff9 $^,ff9 > $@ + +else + +uuencode: + make -f RiscPkg/Rules uuencode uu=encode + +endif + +# ---------------------------------------- +# $(uu) == decode +# ---------------------------------------- + +.PHONY: uudecode + +ifeq (decode,$(uu)) + +uudecode: $(SPRITES) + +%: %.uue + uudecode -o $@,ff9 $^ + +else + +uudecode: + make -f RiscPkg/Rules uudecode uu=decode + +endif Index: RiscPkg/Zip.inc =================================================================== RCS file: RiscPkg/Zip.inc diff -N RiscPkg/Zip.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ RiscPkg/Zip.inc 8 Mar 2005 05:18:05 -0000 1.1 @@ -0,0 +1,18 @@ +RiscPkg/* +Sprites/!* +SysVars/*=24Dir +SysVars/Alias=24* +Apps/File/!Zip/!* +Apps/File/!Zip/zip +Apps/File/!Zip/zipnote +Apps/File/!Zip/zipsplit +Apps/File/!Zip/zipcloak +Apps/File/!Zip/BUGS +Apps/File/!Zip/CHANGES +Apps/File/!Zip/LICENSE +Apps/File/!Zip/MANUAL +Apps/File/!Zip/README +Apps/File/!Zip/README.CR +Apps/File/!Zip/TODO +Apps/File/!Zip/WHATSNEW +Apps/File/!Zip/WHERE Index: Sprites/!zip =================================================================== RCS file: Sprites/!zip diff -N Sprites/!zip --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Sprites/!zip 8 Mar 2005 04:36:11 -0000 1.1 @@ -0,0 +1 @@ +.!Sprites \ No newline at end of file Index: SysVars/Alias=24zip =================================================================== RCS file: SysVars/Alias=24zip diff -N SysVars/Alias=24zip --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ SysVars/Alias=24zip 8 Mar 2005 04:35:23 -0000 1.1 @@ -0,0 +1 @@ +/.zip %*0 \ No newline at end of file Index: SysVars/Alias=24zipcloak =================================================================== RCS file: SysVars/Alias=24zipcloak diff -N SysVars/Alias=24zipcloak --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ SysVars/Alias=24zipcloak 8 Mar 2005 04:35:23 -0000 1.1 @@ -0,0 +1 @@ +/.zipcloak %*0 \ No newline at end of file Index: SysVars/Alias=24zipnote =================================================================== RCS file: SysVars/Alias=24zipnote diff -N SysVars/Alias=24zipnote --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ SysVars/Alias=24zipnote 8 Mar 2005 04:35:23 -0000 1.1 @@ -0,0 +1 @@ +/.zipnote %*0 \ No newline at end of file Index: SysVars/Alias=24zipsplit =================================================================== RCS file: SysVars/Alias=24zipsplit diff -N SysVars/Alias=24zipsplit --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ SysVars/Alias=24zipsplit 8 Mar 2005 04:35:23 -0000 1.1 @@ -0,0 +1 @@ +/.zipsplit %*0 \ No newline at end of file Index: SysVars/Zip=24Dir =================================================================== RCS file: SysVars/Zip=24Dir diff -N SysVars/Zip=24Dir --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ SysVars/Zip=24Dir 8 Mar 2005 04:35:23 -0000 1.1 @@ -0,0 +1 @@ + \ No newline at end of file Index: acorn/Makefile.riscpkg =================================================================== RCS file: acorn/Makefile.riscpkg diff -N acorn/Makefile.riscpkg --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ acorn/Makefile.riscpkg 10 Mar 2005 04:50:24 -0000 1.4 @@ -0,0 +1,106 @@ +# This file is part of the RISC OS Packaging Project distribution of Zip. +# Copyright © 2005 Graham Shaw. +# Distribution and use are subject to the Info-ZIP licence, a copy of which +# may be found in the file ".LICENSE". + +ifndef RULES +RULES = /fixdeps:/Rules.make +endif + +include $(RULES) + +ifndef CCFLAGS +CCFLAGS = -mthrowback -munixlib -mpoke-function-name -O2 +endif + +CPPFLAGS += -I. -D__unixlib -DASMV + +BIN = zip zipnote zipsplit zipcloak + +OBJ_S = \ + acorn/swiven.o \ + acorn/match.o \ + acorn/sendbits.o + +OBJ_zip = \ + zip.o \ + zipfile.o \ + zipup.o \ + fileio.o \ + util.o \ + globals.o \ + crc32.o \ + crctab.o \ + crypt.o \ + ttyio.o \ + acorn/unixlib.o \ + acorn/acornzip.o \ + acorn/swiven.o \ + deflate.o \ + trees.o \ + acorn/match.o \ + acorn/sendbits.o + +OBJ_util = \ + zipfile_.o \ + fileio_.o \ + util_.o \ + globals.o \ + acorn/unixlib.o \ + acorn/acornzip_.o \ + acorn/swiven.o + +OBJ_zipnote = \ + zipnote.o \ + $(OBJ_util) + +OBJ_zipsplit = \ + zipsplit.o \ + $(OBJ_util) + +OBJ_zipcloak = \ + zipcloak.o \ + $(OBJ_util) \ + crctab.o \ + crypt_.o \ + ttyio.o + +OBJ_ALL = $(foreach bin,$(BIN),$(OBJ_$(bin))) + +OBJ_UNIQ = $(sort $(subst _,,$(OBJ_ALL))) + +OBJ_C = $(filter-out $(OBJ_S),$(OBJ_UNIQ)) + +.PHONY: all +all: $(BIN) + +.PHONY: clean +clean: + rm -f $(wildcard *.o) $(wildcard acorn/*.o) + rm -f $(wildcard *.d) $(wildcard acorn/*.d) + rm -f $(BIN) + +.PHONY: distclean +distclean: clean + +zip: $(OBJ_zip) + $(LD) -o $@ $^ + +zipnote: $(OBJ_zipnote) + $(LD) -o $@ $^ + +zipsplit: $(OBJ_zipsplit) + $(LD) -o $@ $^ + +zipcloak: $(OBJ_zipcloak) + $(LD) -o $@ $^ + +%_.o: %.c + $(CC) -c $(CPPFLAGS) -DUTIL $(CCFLAGS) -o $@ $< + +NODEPS = clean distclean +GOALS = $(MAKECMDGOALS) $(if $(MAKECMDGOALS),,all) + +ifneq ($(filter-out $(NODEPS),$(GOALS)),) +include $(OBJ_C:.o=.d) +endif Index: acorn/acornzip.c =================================================================== RCS file: /var/cvs/Zip/acorn/acornzip.c,v retrieving revision 1.1.1.1 retrieving revision 1.3 diff -u -r1.1.1.1 -r1.3 --- acorn/acornzip.c 8 Mar 2005 03:08:05 -0000 1.1.1.1 +++ acorn/acornzip.c 8 Mar 2005 06:16:53 -0000 1.3 @@ -6,6 +6,7 @@ If, for some reason, both of these files are missing, the Info-ZIP license also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html */ +#include #include #include #include "zip.h" @@ -26,12 +27,18 @@ char *readd(DIR *d) /* Return a pointer to the next name in the directory stream d, or NULL if - no more entries or an error occurs. */ + no more entries or an error occurs. Do not return "." or "..". */ { struct dirent *e; + char* name=0; - e = readdir(d); - return (e == NULL ? (char *) NULL : e->d_name); + while (!name && (e = readdir(d))) + { + name = e->d_name; + if (name[0]=='.'&&((name[1]=='.'&&!name[2])||!name[1])) name = 0; + } + + return name; } /* What we have here is a mostly-generic routine using opend()/readd() and */ @@ -64,7 +71,7 @@ do { name = wildtail + strlen(wildtail) - 1; for (;;) - if (name-- <= wildtail || *name == '.') { + if (name-- <= wildtail || *name == PATHSEP) { subwild = name + 1; plug2 = *subwild; *subwild = 0; @@ -78,7 +85,7 @@ } while (!dir && !disk_not_mounted && subwild > wildtail); wildtail = subwild; /* skip past non-wild components */ - if ((subwild = strchr(wildtail + 1, '.')) != NULL) { + if ((subwild = strchr(wildtail + 1, PATHSEP)) != NULL) { /* this "+ 1" dodges the ^^^ hole left by *glue == 0 */ *(subwild++) = 0; /* wildtail = one component pattern */ newlen = strlen(whole) + strlen(subwild) + 32; @@ -104,7 +111,7 @@ strcpy(newwhole + newlen, name); if (subwild) { name = newwhole + strlen(newwhole); - *(name++) = '.'; + *(name++) = PATHSEP; strcpy(name, subwild); e = wild_recurse(newwhole, name); } else @@ -119,7 +126,7 @@ ohforgetit: if (dir) closedir(dir); - if (subwild) *--subwild = '.'; + if (subwild) *--subwild = PATHSEP; if (newwhole) free(newwhole); if (e == ZE_MISS && amatch) e = ZE_OK; @@ -137,6 +144,15 @@ return newname(p, 0, 0); path=p; +#ifdef UNIXLIB + if (strchr(p, ':')==NULL && *p!='/') { + if (!(path=malloc(strlen(p)+3))) { + return ZE_MEM; + } + strcpy(path,"./"); + strcat(path,p); + } +#else if (strchr(p, ':')==NULL && *p!='@') { if (!(path=malloc(strlen(p)+3))) { return ZE_MEM; @@ -144,6 +160,7 @@ strcpy(path,"@."); strcat(path,p); } +#endif toret=wild_recurse(path, path); @@ -203,8 +220,8 @@ } else { strcpy(p, n); a = p + strlen(p); - if (a[-1] != '.') - strcpy(a, "."); + if (a[-1] != PATHSEP) + strcpy(a, PATHSEPSTR); if (dirnames && (m = newname(p, 1, caseflag)) != ZE_OK) { free((zvoid *)p); return m; @@ -264,15 +281,19 @@ /* Find starting point in name before doing malloc */ for(t=tmp;*t;t++) { if (*t=='/') { - *t='.'; + *t=PATHSEP; } - else if (*t=='.') { + else if (*t==PATHSEP) { *t='/'; lastlastdir=lastdir; lastdir=t+1; } } +#ifdef UNIXLIB + t=tmp; + if (t[0]=='.'&&t[1]=='/') t+=2; +#else t=strchr(tmp,'$'); /* skip FS name */ if (t!=NULL) t+=2; /* skip '.' after '$' */ @@ -304,6 +325,7 @@ swapext(lastlastdir,lastdir-1); } } +#endif if (!pathput) t = last(t, PATH_END); @@ -341,16 +363,17 @@ strcpy(x, n); for(t=x;*t;t++) { - if (*t=='.') { + if (*t==PATHSEP) { *t='/'; lastext=t+1; } else if (*t=='/') { - *t='.'; + *t=PATHSEP; lastdir=t+1; } } +#ifndef UNIXLIB if (exts2swap!=NULL && (int)lastext>(int)lastdir) { if (lastdir==NULL) lastdir=x; @@ -358,6 +381,7 @@ swapext(lastdir,lastext-1); } } +#endif return x; } @@ -419,8 +443,8 @@ a file size of -1 */ { struct stat s; /* results of stat() */ - char name[FNMAX]; - int len = strlen(f); + char *name; + unsigned int len = strlen(f); if (f == label) { if (a != NULL) @@ -431,8 +455,13 @@ t->atime = t->mtime = t->ctime = label_utim; return label_time; } + + name = malloc(len+1); + if (!name) + return 0; /* ideally, would like to report alloc-failure warning/error */ + strcpy(name, f); - if (name[len - 1] == '.') + if (name[len - 1] == PATHSEP) name[len - 1] = '\0'; /* not all systems allow stat'ing a file with / appended */ @@ -441,11 +470,13 @@ s.st_mode = (S_IREAD|S_IWRITE|S_IFREG); s.st_size = -1; s.st_mtime = time(&s.st_mtime); - } else if (LSSTAT(name, &s) != 0) + } else if (LSSTAT(name, &s) != 0) { /* Accept about any file kind including directories * (stored with trailing / with -r option) */ + free(name); return 0; + } if (a != NULL) { *a = ((ulg)s.st_mode << 16) | !(s.st_mode & S_IWRITE); @@ -461,6 +492,8 @@ t->ctime = s.st_ctime; } + free(name); + return unix2dostime((time_t *) &s.st_mtime); } @@ -494,7 +527,7 @@ strcpy(name,z->name); - if (name[strlen(name)-1]=='.') { /* remove the last '.' in directory names */ + if (name[strlen(name)-1]==PATHSEP) { /* remove the last '.' in directory names */ name[strlen(name)-1]=0; } Index: acorn/osdep.h =================================================================== RCS file: /var/cvs/Zip/acorn/osdep.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- acorn/osdep.h 8 Mar 2005 03:08:05 -0000 1.1.1.1 +++ acorn/osdep.h 8 Mar 2005 03:46:00 -0000 1.2 @@ -6,17 +6,26 @@ If, for some reason, both of these files are missing, the Info-ZIP license also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html */ -#include "acorn/riscos.h" #define RISCOS + +#define PROCNAME(n) (action == ADD || action == UPDATE ? wild(n) : \ + procname(n, 1)) + +#ifdef __unixlib + +#define UNIXLIB +#include "acorn/unixlib.h" + +#else + +#include "acorn/riscos.h" + #define NO_SYMLINK #define NO_FCNTL_H #define NO_UNISTD_H #define NO_MKTEMP -#define PROCNAME(n) (action == ADD || action == UPDATE ? wild(n) : \ - procname(n, 1)) - #define isatty(a) 1 #define fseek(f,o,t) riscos_fseek((f),(o),(t)) @@ -25,4 +34,6 @@ #ifdef ZCRYPT_INTERNAL # define ZCR_SEED2 (unsigned)3141592654L /* use PI as seed pattern */ +#endif + #endif Index: acorn/swiven.h =================================================================== RCS file: /var/cvs/Zip/acorn/swiven.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- acorn/swiven.h 8 Mar 2005 03:08:05 -0000 1.1.1.1 +++ acorn/swiven.h 8 Mar 2005 03:46:00 -0000 1.2 @@ -35,6 +35,9 @@ os_error *SWI_OS_File_7(char *filename, int loadaddr, int execaddr, int size); /* create an empty file */ +os_error *SWI_OS_File_18(char *filename, int ftype); +/* set filetype */ + os_error *SWI_OS_CLI(char *cmd); /* execute a command */ Index: acorn/swiven.s =================================================================== RCS file: /var/cvs/Zip/acorn/swiven.s,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- acorn/swiven.s 8 Mar 2005 03:08:05 -0000 1.1.1.1 +++ acorn/swiven.s 8 Mar 2005 03:46:00 -0000 1.2 @@ -181,6 +181,19 @@ LDMFD sp!, {r4-r5,pc}^ +; os_error *SWI_OS_File_18(char *filename, int filetype); + + STARTCODE SWI_OS_File_18 + + STMFD sp!, {r4-r5,lr} + MOV r2, r1 + MOV r1, r0 + MOV r0, #18 + SWI OS_File + XOS_Bit + MOVVC r0, #0 + LDMFD sp!, {r4-r5,pc}^ + + ; os_error *SWI_OS_CLI(char *cmd); STARTCODE SWI_OS_CLI Index: acorn/unixlib.c =================================================================== RCS file: acorn/unixlib.c diff -N acorn/unixlib.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ acorn/unixlib.c 8 Mar 2005 04:40:06 -0000 1.1 @@ -0,0 +1,87 @@ +#include "unixlib.h" + +#define __UNIXLIB_INTERNALS + +#include +#include + +int __feature_imagefs_is_file=0; + +int deletedir(char* d) +{ + return rmdir(d); +} + +void setfiletype(char *fname,int ftype) +{ + SWI_OS_File_18(fname,ftype); +} + +void getRISCOSexts(char *envstr) +{ + char *envptr; /* value returned by getenv */ + + envptr = getenv(envstr); + if (envptr == NULL || *envptr == 0) return; + + __sfixinit(envptr); +} + +#undef SWI_OS_FSControl_26 +#undef SWI_OS_FSControl_27 +#undef SWI_OS_GBPB_9 +#undef SWI_OS_File_1 +#undef SWI_OS_File_5 +#undef SWI_OS_File_6 +#undef SWI_OS_File_7 +#undef SWI_OS_File_8 +#undef SWI_OS_File_18 +#undef SWI_OS_FSControl_54 +#undef SWI_OS_FSControl_37 + +static os_error not_recognised={0xcc,"File name not recognised"}; + +os_error *UL_OS_FSControl_26(char *source, char *dest, int actionmask) +{ + char rsource[MAXPATHLEN]; + char rdest[MAXPATHLEN]; + if (!__riscosify_std(source,0,rsource,MAXPATHLEN,0)) + return ¬_recognised; + if (!__riscosify_std(dest,0,rdest,MAXPATHLEN,0)) + return ¬_recognised; + return SWI_OS_FSControl_26(rsource,rdest,actionmask); +} + +os_error *UL_OS_File_1(char *filename, unsigned int loadaddr, + unsigned int execaddr, int attrib) +{ + char rfilename[MAXPATHLEN]; + if (!__riscosify_std(filename,0,rfilename,MAXPATHLEN,0)) + return ¬_recognised; + return SWI_OS_File_1(rfilename,loadaddr,execaddr,attrib); +} + +os_error *UL_OS_File_5(char *filename, int *objtype, unsigned int *loadaddr, + unsigned int *execaddr, int *length, int *attrib) +{ + char rfilename[MAXPATHLEN]; + if (!__riscosify_std(filename,0,rfilename,MAXPATHLEN,0)) + return ¬_recognised; + return SWI_OS_File_5(rfilename,objtype,loadaddr,execaddr,length,attrib); +} + +os_error *UL_OS_File_7(char *filename, int loadaddr, int execaddr, int size) +{ + char rfilename[MAXPATHLEN]; + if (!__riscosify_std(filename,1,rfilename,MAXPATHLEN,0)) + return ¬_recognised; + return SWI_OS_File_7(rfilename,loadaddr,execaddr,size); +} + +os_error *UL_OS_File_18(char *filename, int ftype) +{ + char rfilename[MAXPATHLEN]; + if (!__riscosify_std(filename,0,rfilename,MAXPATHLEN,0)) + return ¬_recognised; + return SWI_OS_File_18(rfilename,ftype); +} Index: acorn/unixlib.h =================================================================== RCS file: acorn/unixlib.h diff -N acorn/unixlib.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ acorn/unixlib.h 8 Mar 2005 04:40:06 -0000 1.1 @@ -0,0 +1,58 @@ +#ifndef __unixlib_h +#define __unixlib_h + +#include +#include +#include +#include +#include +#include + +typedef struct { + int errnum; + char errmess[252]; +} os_error; + +#include "swiven.h" + +#define PATHSEP '/' +#define PATHSEPSTR "/" +#define lenEOL 1 +#define PutNativeEOL *q++ = native(LF); +#define USE_STRM_INPUT +#define USE_FWRITE + +typedef struct { + short ID; + short size; + int ID_2; + unsigned int loadaddr; + unsigned int execaddr; + int attr; + int zero; +} extra_block; + +#define SPARKID 0x4341 /* = "AC" */ +#define SPARKID_2 0x30435241 /* = "ARC0" */ + +#define SWI_OS_FSControl_26 UL_OS_FSControl_26 +#define SWI_OS_FSControl_27 UL_OS_FSControl_27 +#define SWI_OS_GBPB_9 UL_OS_GBPB_9 +#define SWI_OS_File_1 UL_OS_File_1 +#define SWI_OS_File_5 UL_OS_File_5 +#define SWI_OS_File_6 UL_OS_File_6 +#define SWI_OS_File_7 UL_OS_File_7 +#define SWI_OS_File_8 UL_OS_File_8 +#define SWI_OS_File_18 UL_OS_File_18 +#define SWI_OS_FSControl_54 UL_OS_FSControl_54 +#define SWI_OS_FSControl_37 UL_OS_FSControl_37 + +os_error *UL_OS_FSControl_26(char *source, char *dest, int actionmask); +os_error *UL_OS_File_1(char *filename, unsigned int loadaddr, + unsigned int execaddr, int attrib); +os_error *UL_OS_File_5(char *filename, int *objtype, unsigned int *loadaddr, + unsigned int *execaddr, int *length, int *attrib); +os_error *UL_OS_File_7(char *filename, int loadaddr, int execaddr, int size); +os_error *UL_OS_File_18(char *filename, int ftype); + +#endif Index: amiga/amigazip.c =================================================================== RCS file: /var/cvs/Zip/amiga/amigazip.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- amiga/amigazip.c 8 Mar 2005 03:08:06 -0000 1.1.1.1 +++ amiga/amigazip.c 8 Mar 2005 06:16:53 -0000 1.2 @@ -320,8 +320,8 @@ a file size of -1 */ { struct stat s; /* results of stat() */ - char name[FNMAX]; - int len = strlen(f); + char *name; + unsigned int len = strlen(f); if (f == label) { if (a != NULL) @@ -332,19 +332,28 @@ t->atime = t->mtime = t->ctime = label_utim; return label_time; } + + name = malloc(len+1); + if (!name) + return 0; /* ideally, would like to report alloc-failure warning/error */ + strcpy(name, f); if (name[len - 1] == '/') name[len - 1] = '\0'; /* not all systems allow stat'ing a file with / appended */ if (strcmp(f, "-") == 0) { - if (fstat(fileno(stdin), &s) != 0) + if (fstat(fileno(stdin), &s) != 0) { + free(name); error("fstat(stdin)"); - } else if (SSTAT(name, &s) != 0) + } + } else if (SSTAT(name, &s) != 0) { /* Accept about any file kind including directories * (stored with trailing / with -r option) */ + free(name); return 0; + } if (a != NULL) { *a = ((ulg)s.st_mode << 16) | !(s.st_mode & S_IWRITE); @@ -359,6 +368,8 @@ t->mtime = s.st_mtime; t->ctime = s.st_ctime; } + + free(name); return unix2dostime(&s.st_mtime); } Index: aosvs/aosvs.c =================================================================== RCS file: /var/cvs/Zip/aosvs/aosvs.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- aosvs/aosvs.c 8 Mar 2005 03:08:06 -0000 1.1.1.1 +++ aosvs/aosvs.c 8 Mar 2005 06:16:53 -0000 1.2 @@ -294,8 +294,8 @@ a file size of -1 */ { struct stat s; /* results of stat() */ - char name[FNMAX]; - int len = strlen(f); + char *name; + unsigned int len = strlen(f); if (f == label) { if (a != NULL) @@ -306,19 +306,28 @@ t->atime = t->mtime = t->ctime = label_utim; return label_time; } + + name = malloc(len+1); + if (!name) + return 0; /* ideally, would like to report alloc-failure warning/error */ + strcpy(name, f); if (name[len - 1] == '/') name[len - 1] = '\0'; /* not all systems allow stat'ing a file with / appended */ if (strcmp(f, "-") == 0) { - if (fstat(fileno(stdin), &s) != 0) + if (fstat(fileno(stdin), &s) != 0) { + free(name); error("fstat(stdin)"); - } else if (LSSTAT(name, &s) != 0) + } + } else if (LSSTAT(name, &s) != 0) { /* Accept about any file kind including directories * (stored with trailing / with -r option) */ + free(name); return 0; + } if (a != NULL) { *a = ((ulg)s.st_mode << 16) | !(s.st_mode & S_IWRITE); @@ -333,6 +342,8 @@ t->mtime = s.st_mtime; t->ctime = s.st_ctime; } + + free(name); return unix2dostime(&s.st_ctime); } Index: atari/atari.c =================================================================== RCS file: /var/cvs/Zip/atari/atari.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- atari/atari.c 8 Mar 2005 03:08:06 -0000 1.1.1.1 +++ atari/atari.c 8 Mar 2005 06:16:53 -0000 1.2 @@ -532,8 +532,8 @@ a file size of -1 */ { struct stat s; /* results of stat() */ - char name[FNMAX]; - int len = strlen(f); + char *name; + unsigned int len = strlen(f); if (f == label) { if (a != NULL) @@ -544,19 +544,28 @@ t->atime = t->mtime = t->ctime = label_utim; return label_time; } + + name = malloc(len+1); + if (!name) + return 0; /* ideally, would like to report alloc-failure warning/error */ + strcpy(name, f); if (name[len - 1] == '/') name[len - 1] = '\0'; /* not all systems allow stat'ing a file with / appended */ if (strcmp(f, "-") == 0) { - if (fstat(fileno(stdin), &s) != 0) + if (fstat(fileno(stdin), &s) != 0) { + free(name); error("fstat(stdin)"); - } else if (LSSTAT(name, &s) != 0) + } + } else if (LSSTAT(name, &s) != 0) { /* Accept about any file kind including directories * (stored with trailing / with -r option) */ + free(name); return 0; + } if (a != NULL) { /* *a = ((ulg)s.st_mode << 16) | (ulg)GetFileMode(name); */ @@ -569,6 +578,8 @@ t->mtime = s.st_mtime; t->ctime = s.st_ctime; } + + free(name); return unix2dostime(&s.st_mtime); } Index: beos/beos.c =================================================================== RCS file: /var/cvs/Zip/beos/beos.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- beos/beos.c 8 Mar 2005 03:08:06 -0000 1.1.1.1 +++ beos/beos.c 8 Mar 2005 06:16:53 -0000 1.2 @@ -283,8 +283,8 @@ a file size of -1 */ { struct stat s; /* results of stat() */ - char name[FNMAX]; - int len = strlen(f); + char *name; + unsigned int len = strlen(f); if (f == label) { if (a != NULL) @@ -295,18 +295,27 @@ t->atime = t->mtime = t->ctime = label_utim; return label_time; } + + name = malloc(len+1); + if (!name) + return 0; /* ideally, would like to report alloc-failure warning/error */ + strcpy(name, f); if (name[len - 1] == '/') name[len - 1] = '\0'; /* not all systems allow stat'ing a file with / appended */ if (strcmp(f, "-") == 0) { - if (fstat(fileno(stdin), &s) != 0) + if (fstat(fileno(stdin), &s) != 0) { + free(name); error("fstat(stdin)"); - } else if (LSSTAT(name, &s) != 0) + } + } else if (LSSTAT(name, &s) != 0) { /* Accept about any file kind including directories * (stored with trailing / with -r option) */ + free(name); return 0; + } if (a != NULL) { *a = ((ulg)s.st_mode << 16) | !(s.st_mode & S_IWRITE); @@ -321,6 +330,8 @@ t->mtime = s.st_mtime; t->ctime = s.st_mtime; /* best guess (s.st_ctime: last status change!) */ } + + free(name); return unix2dostime(&s.st_mtime); } Index: human68k/human68k.c =================================================================== RCS file: /var/cvs/Zip/human68k/human68k.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- human68k/human68k.c 8 Mar 2005 03:08:06 -0000 1.1.1.1 +++ human68k/human68k.c 8 Mar 2005 06:16:54 -0000 1.2 @@ -231,8 +231,13 @@ a file size of -1 */ { struct stat s; /* results of stat() */ - char name[FNMAX]; - int len = strlen(f), isstdin = !strcmp(f, "-"); + char *name; + unsigned int len = strlen(f); + int isstdin = !strcmp(f, "-"); + + name = malloc(len+1); + if (!name) + return 0; /* ideally, would like to report alloc-failure warning/error */ strcpy(name, f); if (name[len - 1] == '/') @@ -240,13 +245,17 @@ /* not all systems allow stat'ing a file with / appended */ if (isstdin) { - if (fstat(fileno(stdin), &s) != 0) + if (fstat(fileno(stdin), &s) != 0) { + free(name); error("fstat(stdin)"); - } else if (LSSTAT(name, &s) != 0) + } + } else if (LSSTAT(name, &s) != 0) { /* Accept about any file kind including directories * (stored with trailing / with -r option) */ + free(name); return 0; + } if (a != NULL) { int atr = _dos_chmod(name, -1); @@ -262,6 +271,8 @@ t->mtime = s.st_mtime; t->ctime = s.st_ctime; } + + free(name); return unix2dostime(&s.st_mtime); } Index: macos/source/macos.c =================================================================== RCS file: /var/cvs/Zip/macos/source/macos.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- macos/source/macos.c 8 Mar 2005 03:08:06 -0000 1.1.1.1 +++ macos/source/macos.c 8 Mar 2005 06:16:54 -0000 1.2 @@ -601,17 +601,12 @@ a file size of -1 */ { struct stat s; /* results of stat() */ - char name[NAME_MAX]; - int len; AssertStr(f,f) - len = strlen(f); - sstrcpy(name, f); + if (strlen(f) == 0) return 0; - if (len == 0) return 0; - - if (SSTAT(name, &s) != 0) + if (SSTAT(f, &s) != 0) /* Accept about any file kind including directories * (stored with trailing : with -r option) */ Index: msdos/msdos.c =================================================================== RCS file: /var/cvs/Zip/msdos/msdos.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- msdos/msdos.c 8 Mar 2005 03:08:06 -0000 1.1.1.1 +++ msdos/msdos.c 8 Mar 2005 06:16:54 -0000 1.2 @@ -552,8 +552,9 @@ a file size of -1 */ { struct stat s; /* results of stat() */ - char name[FNMAX]; - int len = strlen(f), isstdin = !strcmp(f, "-"); + char *name; + unsigned int len = strlen(f); + int isstdin = !strcmp(f, "-"); if (f == label) { if (a != NULL) @@ -564,20 +565,29 @@ t->atime = t->mtime = t->ctime = label_utim; return label_time; } + + name = malloc(len+1); + if (!name) + return 0; /* ideally, would like to report alloc-failure warning/error */ + strcpy(name, f); if (name[len - 1] == '/') name[len - 1] = '\0'; /* not all systems allow stat'ing a file with / appended */ if (isstdin) { - if (fstat(fileno(stdin), &s) != 0) + if (fstat(fileno(stdin), &s) != 0) { + free(name); error("fstat(stdin)"); + } time((time_t *)&s.st_mtime); /* some fstat()s return time zero */ - } else if (LSSTAT(name, &s) != 0) + } else if (LSSTAT(name, &s) != 0) { /* Accept about any file kind including directories * (stored with trailing / with -r option) */ + free(name); return 0; + } if (a != NULL) *a = ((ulg)s.st_mode << 16) | (isstdin ? 0L : (ulg)GetFileMode(name)); @@ -588,6 +598,8 @@ t->mtime = s.st_mtime; t->ctime = s.st_ctime; } + + free(name); return unix2dostime((time_t *)&s.st_mtime); } Index: os2/os2.c =================================================================== RCS file: /var/cvs/Zip/os2/os2.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- os2/os2.c 8 Mar 2005 03:08:06 -0000 1.1.1.1 +++ os2/os2.c 8 Mar 2005 06:16:54 -0000 1.2 @@ -387,8 +387,9 @@ a file size of -1 */ { struct stat s; /* results of stat() */ - char name[FNMAX]; - int len = strlen(f), isstdin = !strcmp(f, "-"); + char *name; + unsigned int len = strlen(f); + int isstdin = !strcmp(f, "-"); if (f == label) { if (a != NULL) @@ -399,6 +400,11 @@ t->atime = t->mtime = t->ctime = label_utim; return label_time; } + + name = malloc(len+1); + if (!name) + return 0; /* ideally, would like to report alloc-failure warning/error */ + strcpy(name, f); if (name[len - 1] == '/') name[len - 1] = '\0'; @@ -412,11 +418,13 @@ } time(&s.st_ctime); s.st_atime = s.st_mtime = s.st_ctime; - } else if (LSSTAT(name, &s) != 0) + } else if (LSSTAT(name, &s) != 0) { /* Accept about any file kind including directories * (stored with trailing / with -r option) */ + free(name); return 0; + } if (a != NULL) { *a = ((ulg)s.st_mode << 16) | (isstdin ? 0L : (ulg)GetFileMode(name)); @@ -435,6 +443,8 @@ t->mtime = s.st_mtime; t->ctime = s.st_ctime; } + + free(name); return GetFileTime(name); } Index: qdos/qfileio.c =================================================================== RCS file: /var/cvs/Zip/qdos/qfileio.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- qdos/qfileio.c 8 Mar 2005 03:08:06 -0000 1.1.1.1 +++ qdos/qfileio.c 8 Mar 2005 06:16:54 -0000 1.2 @@ -162,8 +162,8 @@ a file size of -1 */ { struct stat s; /* results of stat() */ - char name[FNMAX]; - int len = strlen(f); + char *name; + unsigned int len = strlen(f); if (f == label) { if (a != NULL) @@ -174,18 +174,27 @@ t->atime = t->mtime = t->ctime = label_utim; return label_time; } + + name = malloc(len+1); + if (!name) + return 0; /* ideally, would like to report alloc-failure warning/error */ + strcpy(name, f); if (name[len - 1] == '/') name[len - 1] = '\0'; /* not all systems allow stat'ing a file with / appended */ if (strcmp(f, "-") == 0) { - if (fstat(fileno(stdin), &s) != 0) + if (fstat(fileno(stdin), &s) != 0) { + free(name); error("fstat(stdin)"); - } else if (LSSTAT(name, &s) != 0) + } + } else if (LSSTAT(name, &s) != 0) { /* Accept about any file kind including directories * (stored with trailing / with -r option) */ + free(name); return 0; + } if (a != NULL) { *a = ((ulg)s.st_mode << 16) | !(s.st_mode & S_IWRITE); @@ -200,6 +209,8 @@ t->mtime = s.st_mtime; t->ctime = s.st_ctime; } + + free(name); return unix2dostime(&s.st_mtime); } Index: tandem/tanzip.c =================================================================== RCS file: /var/cvs/Zip/tandem/tanzip.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- tandem/tanzip.c 8 Mar 2005 03:08:06 -0000 1.1.1.1 +++ tandem/tanzip.c 8 Mar 2005 06:16:54 -0000 1.2 @@ -491,7 +491,6 @@ iztimes *t; /* return value: access and modification time */ { struct stat s; - char fname[FILENAME_MAX + 1]; nsk_stat_ov *nsk_ov; if (strcmp(f, "-") == 0) { /* if compressing stdin */ @@ -500,9 +499,7 @@ } } - strcpy(fname, f); - - if (stat(fname, &s) != 0) return 0; + if (stat(f, &s) != 0) return 0; if (a!= NULL) { *a = ((ulg)s.st_mode << 16) | !(s.st_mode & S_IWUSR); Index: theos/theos.c =================================================================== RCS file: /var/cvs/Zip/theos/theos.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- theos/theos.c 8 Mar 2005 03:08:06 -0000 1.1.1.1 +++ theos/theos.c 8 Mar 2005 06:16:54 -0000 1.2 @@ -409,8 +409,8 @@ a device, return a file size of -1 */ { struct stat s; /* results of stat() */ - char name[FNMAX]; - int len = strlen(f); + char *name; + unsigned int len = strlen(f); if (f == label) { if (a != NULL) @@ -421,6 +421,11 @@ t->atime = t->mtime = t->ctime = label_utim; return label_time; } + + name = malloc(len+1); + if (!name) + return 0; /* ideally, would like to report alloc-failure warning/error */ + strcpy(name, f); if (name[len - 1] == '/' || name[len - 1] == '.') @@ -428,13 +433,17 @@ /* not all systems allow stat'ing a file with / appended */ if (strcmp(f, "-") == 0) { - if (fstat(fileno(stdin), &s) != 0) + if (fstat(fileno(stdin), &s) != 0) { + free(name); error("fstat(stdin)"); - } else if (LSSTAT(name, &s) != 0) + } + } else if (LSSTAT(name, &s) != 0) { /* Accept about any file kind including directories * (stored with trailing / with -r option) */ + free(name); return 0; + } if (a != NULL) { *a = ((ulg)s.st_mode << 16) | !(s.st_mode & S_IWRITE); @@ -442,8 +451,8 @@ || (s.st_mode & S_IFMT) == S_IFLIB) { *a |= MSDOS_DIR_ATTR; } -/* Map Theos' hidden attribute to DOS's hidden attribute */ - if (!st.st_protect & 0x80)) + /* Map Theos' hidden attribute to DOS's hidden attribute */ + if (!(st.st_protect & 0x80)) *a |= MSDOS_HIDDEN_ATTR; *a |= ((ulg) s.st_protect) << 8; } @@ -454,6 +463,9 @@ t->mtime = s.st_mtime; t->ctime = t->mtime; /* best guess, (s.st_ctime: last status change!!) */ } + + free(name); + return unix2dostime(&s.st_mtime); } /* Index: tops20/tops20.c =================================================================== RCS file: /var/cvs/Zip/tops20/tops20.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- tops20/tops20.c 8 Mar 2005 03:08:06 -0000 1.1.1.1 +++ tops20/tops20.c 8 Mar 2005 06:16:54 -0000 1.2 @@ -422,8 +422,8 @@ a file size of -1 */ { struct stat s; /* results of stat() */ - char name[FNMAX]; - int len = strlen(f); + char *name; + unsigned int len = strlen(f); if (f == label) { if (a != NULL) @@ -434,19 +434,28 @@ t->atime = t->mtime = t->ctime = label_utim; return label_time; } + + name = malloc(len+1); + if (!name) + return 0; /* ideally, would like to report alloc-failure warning/error */ + strcpy(name, f); if (name[len - 1] == '/') name[len - 1] = '\0'; /* not all systems allow stat'ing a file with / appended */ if (strcmp(f, "-") == 0) { - if (fstat(fileno(stdin), &s) != 0) + if (fstat(fileno(stdin), &s) != 0) { + free(name); error("fstat(stdin)"); - } else if (LSSTAT(name, &s) != 0) + } + } else if (LSSTAT(name, &s) != 0) { /* Accept about any file kind including directories * (stored with trailing / with -r option) */ + free(name); return 0; + } if (a != NULL) { *a = ((ulg)s.st_mode << 16) | !(s.st_mode & S_IWRITE); @@ -461,6 +470,8 @@ t->mtime = s.st_mtime; t->ctime = s.st_ctime; } + + free(name); return unix2dostime(&s.st_mtime); } Index: unix/unix.c =================================================================== RCS file: /var/cvs/Zip/unix/unix.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- unix/unix.c 8 Mar 2005 03:08:06 -0000 1.1.1.1 +++ unix/unix.c 8 Mar 2005 06:16:54 -0000 1.2 @@ -319,8 +319,8 @@ a file size of -1 */ { struct stat s; /* results of stat() */ - char name[FNMAX]; - int len = strlen(f); + char *name; + unsigned int len = strlen(f); if (f == label) { if (a != NULL) @@ -331,19 +331,28 @@ t->atime = t->mtime = t->ctime = label_utim; return label_time; } + + name = malloc(len+1); + if (!name) + return 0; /* ideally, would like to report alloc-failure warning/error */ + strcpy(name, f); if (name[len - 1] == '/') name[len - 1] = '\0'; /* not all systems allow stat'ing a file with / appended */ if (strcmp(f, "-") == 0) { - if (fstat(fileno(stdin), &s) != 0) + if (fstat(fileno(stdin), &s) != 0) { + free(name); error("fstat(stdin)"); + } } - else if (LSSTAT(name, &s) != 0) + else if (LSSTAT(name, &s) != 0) { /* Accept about any file kind including directories * (stored with trailing / with -r option) */ + free(name); return 0; + } if (a != NULL) { #ifndef OS390 @@ -367,7 +376,7 @@ { mode_t legacy_modes; - /* Initialize with permission bits - which are not implementation optional */ + /* Initialize with permission bits--which are not implementation-optional */ legacy_modes = s.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX); if (S_ISDIR(s.st_mode)) legacy_modes |= UNX_IFDIR; @@ -397,6 +406,9 @@ t->mtime = s.st_mtime; t->ctime = t->mtime; /* best guess, (s.st_ctime: last status change!!) */ } + + free(name); + return unix2dostime(&s.st_mtime); } Index: vms/vmszip.c =================================================================== RCS file: /var/cvs/Zip/vms/vmszip.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- vms/vmszip.c 8 Mar 2005 03:08:06 -0000 1.1.1.1 +++ vms/vmszip.c 8 Mar 2005 06:16:54 -0000 1.2 @@ -488,8 +488,8 @@ a file size of -1 */ { struct stat s; /* results of stat() */ - char name[FNMAX]; - int len = strlen(f); + char *name; + unsigned int len = strlen(f); if (f == label) { if (a != NULL) @@ -500,19 +500,28 @@ t->atime = t->mtime = t->ctime = label_utim; return label_time; } + + name = malloc(len+1); + if (!name) + return 0; /* ideally, would like to report alloc-failure warning/error */ + strcpy(name, f); if (name[len - 1] == '/') name[len - 1] = '\0'; /* not all systems allow stat'ing a file with / appended */ if (strcmp(f, "-") == 0) { - if (fstat(fileno(stdin), &s) != 0) + if (fstat(fileno(stdin), &s) != 0) { + free(name); error("fstat(stdin)"); - } else if (LSSTAT(name, &s) != 0) + } + } else if (LSSTAT(name, &s) != 0) { /* Accept about any file kind including directories * (stored with trailing / with -r option) */ + free(name); return 0; + } if (a != NULL) { *a = ((ulg)s.st_mode << 16) | !(s.st_mode & S_IWRITE); @@ -531,6 +540,8 @@ #endif t->ctime = s.st_ctime; } + + free(name); #ifdef USE_MTIME return unix2dostime((time_t *)&s.st_mtime); /* Use modification time in VMS */ Index: win32/win32zip.c =================================================================== RCS file: /var/cvs/Zip/win32/win32zip.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- win32/win32zip.c 8 Mar 2005 03:08:06 -0000 1.1.1.1 +++ win32/win32zip.c 8 Mar 2005 06:16:54 -0000 1.2 @@ -522,8 +522,9 @@ a file size of -1 */ { struct stat s; /* results of stat() */ - char name[FNMAX]; - int len = strlen(f), isstdin = !strcmp(f, "-"); + char *name; + unsigned int len = strlen(f); + int isstdin = !strcmp(f, "-"); if (f == label) { if (a != NULL) @@ -534,20 +535,29 @@ t->atime = t->mtime = t->ctime = label_utim; return label_time; } + + name = malloc(len+1); + if (!name) + return 0; /* ideally, would like to report alloc-failure warning/error */ + strcpy(name, f); if (MBSRCHR(name, '/') == (name + len - 1)) name[len - 1] = '\0'; /* not all systems allow stat'ing a file with / appended */ if (isstdin) { - if (fstat(fileno(stdin), &s) != 0) + if (fstat(fileno(stdin), &s) != 0) { + free(name); error("fstat(stdin)"); + } time((time_t *)&s.st_mtime); /* some fstat()s return time zero */ - } else if (LSSTAT(name, &s) != 0) + } else if (LSSTAT(name, &s) != 0) { /* Accept about any file kind including directories * (stored with trailing / with -r option) */ + free(name); return 0; + } if (a != NULL) { *a = ((ulg)s.st_mode << 16) | (isstdin ? 0L : (ulg)GetFileMode(name)); @@ -559,6 +569,8 @@ t->mtime = s.st_mtime; t->ctime = s.st_ctime; } + + free(name); return unix2dostime((time_t *)&s.st_mtime); }