X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=unzip.c;h=55185a95c8974a81dff4a2e035df030e4d86e51f;hb=5e7660c3dbe55d8580d9a79a1e71f25359ecf252;hp=349808aee8d0331eeba634893831d3e7da133914;hpb=302189d124ed5849c2589ea92e912eb24fdc4ab3;p=debian%2Fgzip diff --git a/unzip.c b/unzip.c index 349808a..55185a9 100644 --- a/unzip.c +++ b/unzip.c @@ -1,8 +1,23 @@ /* unzip.c -- decompress files in gzip or pkzip format. - * Copyright (C) 1992-1993 Jean-loup Gailly - * This is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License, see the file COPYING. - * + + Copyright (C) 1997-1999, 2009-2010 Free Software Foundation, Inc. + Copyright (C) 1992-1993 Jean-loup Gailly + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* * The code in this file is derived from the file funzip.c written * and put in the public domain by Mark Adler. */ @@ -13,10 +28,6 @@ either deflated or stored. */ -#ifdef RCSID -static char rcsid[] = "$Id: unzip.c,v 0.13 1993/06/10 13:29:00 jloup Exp $"; -#endif - #include #include "tailor.h" #include "gzip.h" @@ -28,7 +39,7 @@ static char rcsid[] = "$Id: unzip.c,v 0.13 1993/06/10 13:29:00 jloup Exp $"; #define CRPFLG 1 /* bit for encrypted entry */ #define EXTFLG 8 /* bit for extended local header */ #define LOCHOW 8 /* offset of compression method */ -#define LOCTIM 10 /* file mod time (for decryption) */ +/* #define LOCTIM 10 UNUSED file mod time (for decryption) */ #define LOCCRC 14 /* offset of crc */ #define LOCSIZ 18 /* offset of compressed size */ #define LOCLEN 22 /* offset of uncompressed length */ @@ -62,7 +73,7 @@ int check_zipfile(in) if (inptr > insize || LG(h) != LOCSIG) { fprintf(stderr, "\n%s: %s: not a valid zip file\n", - progname, ifname); + program_name, ifname); exit_code = ERROR; return ERROR; } @@ -70,7 +81,7 @@ int check_zipfile(in) if (method != STORED && method != DEFLATED) { fprintf(stderr, "\n%s: %s: first entry not deflated or stored -- use unzip\n", - progname, ifname); + program_name, ifname); exit_code = ERROR; return ERROR; } @@ -78,7 +89,7 @@ int check_zipfile(in) /* If entry encrypted, decrypt and validate encryption header */ if ((decrypt = h[LOCFLG] & CRPFLG) != 0) { fprintf(stderr, "\n%s: %s: encrypted file -- use unzip\n", - progname, ifname); + program_name, ifname); exit_code = ERROR; return ERROR; } @@ -123,9 +134,9 @@ int unzip(in, out) int res = inflate(); if (res == 3) { - error("out of memory"); + xalloc_die (); } else if (res != 0) { - error("invalid compressed data--format violated"); + gzip_error ("invalid compressed data--format violated"); } } else if (pkzip && method == STORED) { @@ -135,7 +146,7 @@ int unzip(in, out) if (n != LG(inbuf + LOCSIZ) - (decrypt ? RAND_HEAD_LEN : 0)) { fprintf(stderr, "len %ld, siz %ld\n", n, LG(inbuf + LOCSIZ)); - error("invalid compressed data--length mismatch"); + gzip_error ("invalid compressed data--length mismatch"); } while (n--) { uch c = (uch)get_byte(); @@ -143,7 +154,7 @@ int unzip(in, out) } flush_window(); } else { - error("internal error, invalid method"); + gzip_error ("internal error, invalid method"); } /* Get the crc and original length */ @@ -173,12 +184,12 @@ int unzip(in, out) /* Validate decompression */ if (orig_crc != updcrc(outbuf, 0)) { fprintf(stderr, "\n%s: %s: invalid compressed data--crc error\n", - progname, ifname); + program_name, ifname); err = ERROR; } if (orig_len != (ulg)(bytes_out & 0xffffffff)) { fprintf(stderr, "\n%s: %s: invalid compressed data--length error\n", - progname, ifname); + program_name, ifname); err = ERROR; } @@ -187,12 +198,12 @@ int unzip(in, out) if (to_stdout) { WARN((stderr, "%s: %s has more than one entry--rest ignored\n", - progname, ifname)); + program_name, ifname)); } else { /* Don't destroy the input zip file */ fprintf(stderr, "%s: %s has more than one entry -- unchanged\n", - progname, ifname); + program_name, ifname); err = ERROR; } }