diff -ur unzip-5.51/extract.c unzip-5.51-lhh/extract.c --- unzip-5.51/extract.c 2004-04-15 20:58:00.000000000 -0400 +++ unzip-5.51-lhh/extract.c 2004-06-18 16:26:57.000000000 -0400 @@ -299,16 +299,16 @@ __GDEF { unsigned i, j; - long cd_bufstart; + ulg cd_bufstart; uch *cd_inptr; int cd_incnt; ulg filnum=0L, blknum=0L; int reached_end, no_endsig_found; int error, error_in_archive=PK_COOL; int *fn_matched=NULL, *xn_matched=NULL; - unsigned members_processed; + ulg members_processed; ulg num_skipped=0L, num_bad_pwd=0L; - LONGINT old_extra_bytes = 0L; + ulg old_extra_bytes = 0L; #ifdef SET_DIR_ATTRIB unsigned num_dirs=0; direntry *dirlist=(direntry *)NULL, **sorted_dirlist=(direntry **)NULL; @@ -539,7 +539,7 @@ G.cur_zipfile_bufstart = ftell((FILE *)G.zipfd); #else /* !USE_STRM_INPUT */ G.cur_zipfile_bufstart = - lseek(G.zipfd, (LONGINT)cd_bufstart, SEEK_SET); + lseek64(G.zipfd, (ulg)cd_bufstart, SEEK_SET); #endif /* ?USE_STRM_INPUT */ read(G.zipfd, (char *)G.inbuf, INBUFSIZ); /* been here before... */ G.inptr = cd_inptr; @@ -902,7 +902,7 @@ unsigned i; int renamed, query; int skip_entry; - long bufstart, inbuf_offset, request; + ulg bufstart, inbuf_offset, request; int error, errcode; /* possible values for local skip_entry flag: */ @@ -936,7 +936,8 @@ Trace((stderr, "debug: bufstart = %ld, cur_zipfile_bufstart = %ld\n", bufstart, G.cur_zipfile_bufstart)); - if (request < 0) { + if (request > MAX_ZIP_SIZE) { /* > 2^32 - 8193 */ + printf("request = 0x%lu\n", (ulg)request); Info(slide, 0x401, ((char *)slide, LoadFarStringSmall(SeekMsg), G.zipfn, LoadFarString(ReportMsg))); error_in_archive = PK_ERR; @@ -954,7 +955,8 @@ "debug: bufstart = %ld, cur_zipfile_bufstart = %ld\n", bufstart, G.cur_zipfile_bufstart)); /* try again */ - if (request < 0) { + if (request > MAX_ZIP_SIZE) { /* > 2^32 - 8193 */ + printf("retry - request = 0x%lu\n", (ulg)request); Trace((stderr, "debug: recompensated request still < 0\n")); Info(slide, 0x401, ((char *)slide, @@ -976,7 +978,7 @@ G.cur_zipfile_bufstart = ftell((FILE *)G.zipfd); #else /* !USE_STRM_INPUT */ G.cur_zipfile_bufstart = - lseek(G.zipfd, (LONGINT)bufstart, SEEK_SET); + lseek64(G.zipfd, (ulg)bufstart, SEEK_SET); #endif /* ?USE_STRM_INPUT */ if ((G.incnt = read(G.zipfd,(char *)G.inbuf,INBUFSIZ)) <= 0) { diff -ur unzip-5.51/fileio.c unzip-5.51-lhh/fileio.c --- unzip-5.51/fileio.c 2004-05-22 21:01:20.000000000 -0400 +++ unzip-5.51-lhh/fileio.c 2004-06-18 16:26:57.000000000 -0400 @@ -112,6 +112,8 @@ /****************************/ /* Strings used in fileio.c */ /****************************/ +static ZCONST char Far ZipFileTooBig[] = + "error: Zip file too big (greater than %lu bytes)\n"; static ZCONST char Far CannotOpenZipfile[] = "error: cannot open zipfile [ %s ]\n %s"; @@ -183,6 +185,7 @@ int open_input_file(__G) /* return 1 if open failed */ __GDEF { + struct stat64 sb; /* * open the zipfile for reading and in BINARY mode to prevent cr/lf * translation, which would corrupt the bitstreams @@ -201,9 +204,9 @@ G.zipfd = fopen(G.zipfn, FOPR); #else /* !USE_STRM_INPUT */ # ifdef O_BINARY - G.zipfd = open(G.zipfn, O_RDONLY | O_BINARY); + G.zipfd = open(G.zipfn, O_RDONLY | O_BINARY | O_LARGEFILE); # else - G.zipfd = open(G.zipfn, O_RDONLY); + G.zipfd = open(G.zipfn, O_RDONLY | O_LARGEFILE); # endif #endif /* ?USE_STRM_INPUT */ #endif /* ?CMS_MVS */ @@ -221,6 +224,13 @@ G.zipfn, strerror(errno))); return 1; } + + fstat64(G.zipfd, &sb); + if (sb.st_size > MAX_ZIP_SIZE) { + Info(slide, 0x401, ((char *)slide, + LoadFarString(ZipFileTooBig), + ((ulg)MAX_ZIP_SIZE))); + } return 0; } /* end function open_input_file() */ @@ -238,6 +248,7 @@ int open_outfile(__G) /* return 1 if fail */ __GDEF { + int fd; #ifdef DLL if (G.redirect_data) return (redirect_outfile(__G) == FALSE); @@ -259,7 +270,7 @@ } #endif /* BORLAND_STAT_BUG */ #ifdef SYMLINKS - if (SSTAT(G.filename, &G.statbuf) == 0 || lstat(G.filename,&G.statbuf) == 0) + if (SSTAT(G.filename, &G.statbuf) == 0 || lstat64(G.filename,&G.statbuf) == 0) #else if (SSTAT(G.filename, &G.statbuf) == 0) #endif /* ?SYMLINKS */ @@ -413,7 +424,9 @@ #endif /* NOVELL_BUG_FAILSAFE */ Trace((stderr, "open_outfile: doing fopen(%s) for writing\n", FnFilter1(G.filename))); - if ((G.outfile = fopen(G.filename, FOPW)) == (FILE *)NULL) { + + fd = open(G.filename, O_WRONLY | O_LARGEFILE | O_CREAT); + if ((G.outfile = fdopen(fd, FOPW)) == (FILE *)NULL) { Info(slide, 0x401, ((char *)slide, LoadFarString(CannotCreateFile), FnFilter1(G.filename))); return 1; @@ -657,7 +670,7 @@ int seek_zipf(__G__ abs_offset) __GDEF - LONGINT abs_offset; + ulg abs_offset; { /* * Seek to the block boundary of the block which includes abs_offset, @@ -678,11 +691,11 @@ * PK_EOF if seeking past end of zipfile * PK_OK when seek was successful */ - LONGINT request = abs_offset + G.extra_bytes; - LONGINT inbuf_offset = request % INBUFSIZ; - LONGINT bufstart = request - inbuf_offset; + ulg request = abs_offset + G.extra_bytes; + ulg inbuf_offset = request % INBUFSIZ; + ulg bufstart = request - inbuf_offset; - if (request < 0) { + if (request > (ulg)MAX_ZIP_SIZE) { Info(slide, 1, ((char *)slide, LoadFarStringSmall(SeekMsg), G.zipfn, LoadFarString(ReportMsg))); return(PK_BADERR); @@ -694,7 +707,7 @@ fseek(G.zipfd, (LONGINT)bufstart, SEEK_SET); G.cur_zipfile_bufstart = ftell(G.zipfd); #else /* !USE_STRM_INPUT */ - G.cur_zipfile_bufstart = lseek(G.zipfd, (LONGINT)bufstart, SEEK_SET); + G.cur_zipfile_bufstart = lseek64(G.zipfd, bufstart, SEEK_SET); #endif /* ?USE_STRM_INPUT */ Trace((stderr, " request = %ld, (abs+extra) = %ld, inbuf_offset = %ld\n", @@ -1850,7 +1863,7 @@ Trace((stderr, "check_for_newer: doing lstat(%s)\n", FnFilter1(filename))); /* GRR OPTION: could instead do this test ONLY if G.symlnk is true */ - if (lstat(filename, &G.statbuf) == 0) { + if (lstat64(filename, &G.statbuf) == 0) { Trace((stderr, "check_for_newer: lstat(%s) returns 0: symlink does exist\n", FnFilter1(filename))); @@ -1867,7 +1880,7 @@ #ifdef SYMLINKS /* GRR OPTION: could instead do this test ONLY if G.symlnk is true */ - if (lstat(filename, &G.statbuf) == 0 && S_ISLNK(G.statbuf.st_mode)) { + if (lstat64(filename, &G.statbuf) == 0 && S_ISLNK(G.statbuf.st_mode)) { Trace((stderr, "check_for_newer: %s is a symbolic link\n", FnFilter1(filename))); if (QCOND2 && !IS_OVERWRT_ALL) diff -ur unzip-5.51/globals.h unzip-5.51-lhh/globals.h --- unzip-5.51/globals.h 2004-02-25 20:23:18.000000000 -0500 +++ unzip-5.51-lhh/globals.h 2004-06-18 16:26:57.000000000 -0400 @@ -247,16 +247,20 @@ #else int zipfd; /* zipfile file handle */ #endif - LONGINT ziplen; - LONGINT cur_zipfile_bufstart; /* extract_or_test, readbuf, ReadByte */ - LONGINT extra_bytes; /* used in unzip.c, misc.c */ + ulg ziplen; + ulg cur_zipfile_bufstart; /* extract_or_test, readbuf, ReadByte */ + ulg extra_bytes; /* used in unzip.c, misc.c */ uch *extra_field; /* Unix, VMS, Mac, OS/2, Acorn, ... */ uch *hold; local_file_hdr lrec; /* used in unzip.c, extract.c */ cdir_file_hdr crec; /* used in unzip.c, extract.c, misc.c */ ecdir_rec ecrec; /* used in unzip.c, extract.c */ - struct stat statbuf; /* used by main, mapname, check_for_newer */ +#ifdef _LARGEFILE64_SOURCE + struct stat64 statbuf; /* used by main, mapname, check_for_newer */ +#else + struct stat statbuf; /* used by main, mapname, check_for_newer */ +#endif int mem_mode; uch *outbufptr; /* extract.c static */ diff -ur unzip-5.51/list.c unzip-5.51-lhh/list.c --- unzip-5.51/list.c 2004-03-01 14:03:02.000000000 -0500 +++ unzip-5.51-lhh/list.c 2004-06-21 12:57:05.000000000 -0400 @@ -62,7 +62,7 @@ "%8lu %-7s%8lu %4s %02u%c%02u%c%02u %02u:%02u %08lx %c"; static ZCONST char Far LongFileTrailer[] = "-------- ------- --- \ - -------\n%8lu %8lu %4s %lu file%s\n"; + -------\n%8llu %8llu %4s %lu file%s\n"; #ifdef OS2_EAS static ZCONST char Far ShortHdrStats[] = "%9lu %6lu %6lu %02u%c%02u%c%02u %02u:%02u %c"; @@ -76,7 +76,7 @@ static ZCONST char Far ShortHdrStats[] = "%9lu %02u%c%02u%c%02u %02u:%02u %c"; static ZCONST char Far ShortFileTrailer[] = " -------- \ - -------\n%9lu %lu file%s\n"; + -------\n%9llu %lu file%s\n"; #endif /* ?OS2_EAS */ #endif /* !WINDLL */ @@ -105,7 +105,8 @@ struct tm *t; #endif unsigned yr, mo, dy, hh, mm; - ulg csiz, tot_csize=0L, tot_ucsize=0L; + ulg csiz; + unsigned long long tot_csize=0, tot_ucsize=0; #ifdef OS2_EAS ulg ea_size, tot_easize=0L, tot_eafiles=0L; ulg acl_size, tot_aclsize=0L, tot_aclfiles=0L; diff -ur unzip-5.51/process.c unzip-5.51-lhh/process.c --- unzip-5.51/process.c 2003-10-19 18:52:04.000000000 -0400 +++ unzip-5.51-lhh/process.c 2004-06-18 16:26:57.000000000 -0400 @@ -915,7 +915,7 @@ long searchlen; { int i, numblks, found=FALSE; - LONGINT tail_len; + ulg tail_len; ec_byte_rec byterec; @@ -923,8 +923,8 @@ Treat case of short zipfile separately. ---------------------------------------------------------------------------*/ - if (G.ziplen <= INBUFSIZ) { - lseek(G.zipfd, 0L, SEEK_SET); + if ((unsigned long)G.ziplen <= (unsigned long)INBUFSIZ) { + lseek64(G.zipfd, 0L, SEEK_SET); if ((G.incnt = read(G.zipfd,(char *)G.inbuf,(unsigned int)G.ziplen)) == (int)G.ziplen) @@ -951,7 +951,7 @@ fseek((FILE *)G.zipfd, G.ziplen-tail_len, SEEK_SET); G.cur_zipfile_bufstart = ftell((FILE *)G.zipfd); #else /* !USE_STRM_INPUT */ - G.cur_zipfile_bufstart = lseek(G.zipfd, G.ziplen-tail_len, + G.cur_zipfile_bufstart = lseek64(G.zipfd, G.ziplen-tail_len, SEEK_SET); #endif /* ?USE_STRM_INPUT */ if ((G.incnt = read(G.zipfd, (char *)G.inbuf, @@ -985,7 +985,7 @@ for (i = 1; !found && (i <= numblks); ++i) { G.cur_zipfile_bufstart -= INBUFSIZ; - lseek(G.zipfd, G.cur_zipfile_bufstart, SEEK_SET); + lseek64(G.zipfd, G.cur_zipfile_bufstart, SEEK_SET); if ((G.incnt = read(G.zipfd,(char *)G.inbuf,INBUFSIZ)) != INBUFSIZ) break; /* fall through and fail */ diff -ur unzip-5.51/unix/Makefile unzip-5.51-lhh/unix/Makefile --- unzip-5.51/unix/Makefile 2004-06-21 15:07:16.936126502 -0400 +++ unzip-5.51-lhh/unix/Makefile 2004-06-18 16:26:57.000000000 -0400 @@ -783,7 +783,7 @@ # Linux (Posix, approximately SysV): virtually any version since before 0.96, # for any platform. Change "-O" to "-O3" or whatever, as desired... linux_noasm: unix_make - $(MAKE) unzips CC=gcc LD=gcc CF="$(RPM_OPT_FLAGS) -D_GNU_SOURCE -Wall -I. $(LOC)" + $(MAKE) unzips CC=gcc LD=gcc CF="$(RPM_OPT_FLAGS) -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -Wall -I. $(LOC)" # Linux with lcc compiler: __inline__ (stat.h) not recognized, and must edit # /usr/include/gnu/types.h to get rid of "long long" if __LCC__ defined. -O3 diff -ur unzip-5.51/unzip.h unzip-5.51-lhh/unzip.h --- unzip-5.51/unzip.h 2004-05-22 21:04:23.000000000 -0400 +++ unzip-5.51-lhh/unzip.h 2004-06-18 16:26:57.000000000 -0400 @@ -591,6 +591,8 @@ #define UZ_ST_CONTINUE 0 #define UZ_ST_BREAK 1 +#define MAX_ZIP_SIZE 0xffffdffe + /*--------------------------------------------------------------------------- Prototypes for public UnZip API (DLL) functions. diff -ur unzip-5.51/unzpriv.h unzip-5.51-lhh/unzpriv.h --- unzip-5.51/unzpriv.h 2004-03-01 13:09:04.000000000 -0500 +++ unzip-5.51-lhh/unzpriv.h 2004-06-18 16:26:57.000000000 -0400 @@ -775,9 +775,9 @@ #endif #ifndef SSTAT # ifdef WILD_STAT_BUG -# define SSTAT(path,pbuf) (iswild(path) || stat(path,pbuf)) +# define SSTAT(path,pbuf) (iswild(path) || stat64(path,pbuf)) # else -# define SSTAT stat +# define SSTAT stat64 # endif #endif #ifndef STRNICMP @@ -1860,7 +1860,7 @@ unsigned readbuf OF((__GPRO__ char *buf, register unsigned len)); int readbyte OF((__GPRO)); int fillinbuf OF((__GPRO)); -int seek_zipf OF((__GPRO__ LONGINT abs_offset)); +int seek_zipf OF((__GPRO__ ulg abs_offset)); #ifdef FUNZIP int flush OF((__GPRO__ ulg size)); /* actually funzip.c */ #else