Hi all,
I have found the source of the issue I reported to clamav-users last week (originally with a subject of "Input/Output error with .zip file under 0.84"), with the help of a pointer from Andrey Melnikoff.
libz has support for method 9 files, but the support is not compiled in per default (in the subdir contrib/infback9).
There we can read:
* This header file and associated patches provide a decoder for PKWare's * undocumented deflate64 compression method (method 9). Use with infback9.c, * inftree9.h, inftree9.c, and inffix9.h. These patches are not supported. * This should be compiled with zlib, since it uses zutil.h and zutil.o. * This code has not yet been tested on 16-bit architectures. See the * comments in zlib.h for inflateBack() usage. These functions are used * identically, except that there is no windowBits parameter, and a 64K * window must be provided. Also if int's are 16 bits, then a zero for * the third parameter of the "out" function actually means 65536UL. * zlib.h must be included before this header file.
So clamav should check if there is a zlib around with infback9 support, and then use inflateBack9Init(), inflateBack9() instead of inflate_init2() and inflate(). Any chance Guido or Tomi that you can provide patches for this ?
in libz.h we read:
inflateBack() does a raw inflate with a single call using a call-back interface for input and output. This is more efficient than inflate() for file i/o applications in that it avoids copying between the output and the sliding window by simply making the window itself the output buffer. This function trusts the application to not change the output buffer passed by the output function, at least until inflateBack() returns.
To add support for type9 files in libz is easy, copy the files in contrib/infback9 to the main zlib dir and then add this patch:
--- Makefile.in.orig Wed Sep 15 16:27:20 2004 +++ Makefile.in Thu May 12 14:38:23 2005 @@ -47,7 +47,7 @@ man3dir = ${mandir}/man3
OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ - zutil.o inflate.o infback.o inftrees.o inffast.o + zutil.o inflate.o infback.o infback9.o inftree9.o inftrees.o inffast.o
OBJA = # to use the asm code: make OBJA=match.o @@ -147,6 +147,8 @@ inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h +infback9.o: zutil.h zlib.h zconf.h inftree9.h inflate9.h inffast.h infback9.h +inftree9.o: zutil.h zlib.h zconf.h inftree9.h inflate9.h inffast.h infback9.h inftrees.o: zutil.h zlib.h zconf.h inftrees.h minigzip.o: zlib.h zconf.h trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
I guess those routines could be directly compiled into clamav. To use inflateBack9() instead of inflate() in clamav is a bit more complicated since one has to deal with the raw streams ...
Martin _______________________________________________ http://lurker.clamav.net/list/clamav-devel.html