diff -dPNur clamav-0.95.2/libclamav/filetypes.c clamav-0.95.2-ds/libclamav/filetypes.c --- clamav-0.95.2/libclamav/filetypes.c 2009-03-16 19:37:27.000000000 +0100 +++ clamav-0.95.2-ds/libclamav/filetypes.c 2009-09-09 20:09:58.000000000 +0200 @@ -62,6 +62,7 @@ { "CL_TYPE_ZIP", CL_TYPE_ZIP }, { "CL_TYPE_BZ", CL_TYPE_BZ }, { "CL_TYPE_RAR", CL_TYPE_RAR }, + { "CL_TYPE_7ZIP", CL_TYPE_7ZIP }, { "CL_TYPE_ARJ", CL_TYPE_ARJ }, { "CL_TYPE_MSSZDD", CL_TYPE_MSSZDD }, { "CL_TYPE_MSOLE2", CL_TYPE_MSOLE2 }, diff -dPNur clamav-0.95.2/libclamav/filetypes.h clamav-0.95.2-ds/libclamav/filetypes.h --- clamav-0.95.2/libclamav/filetypes.h 2009-03-16 19:37:27.000000000 +0100 +++ clamav-0.95.2-ds/libclamav/filetypes.h 2009-09-09 20:09:58.000000000 +0200 @@ -48,6 +48,7 @@ CL_TYPE_BZ, CL_TYPE_RAR, CL_TYPE_ARJ, + CL_TYPE_7ZIP, CL_TYPE_MSSZDD, CL_TYPE_MSOLE2, CL_TYPE_MSCAB, diff -dPNur clamav-0.95.2/libclamav/filetypes_int.h clamav-0.95.2-ds/libclamav/filetypes_int.h --- clamav-0.95.2/libclamav/filetypes_int.h 2009-03-16 19:37:27.000000000 +0100 +++ clamav-0.95.2-ds/libclamav/filetypes_int.h 2009-09-09 21:36:17.000000000 +0200 @@ -35,6 +35,7 @@ */ static const char *ftypes_int[] = { + "0:0:377abcaf271c:7ZIP:CL_TYPE_ANY:CL_TYPE_7ZIP", "0:0:000001b3:MPEG video stream:CL_TYPE_ANY:CL_TYPE_IGNORED", "0:0:000001ba:MPEG sys stream:CL_TYPE_ANY:CL_TYPE_IGNORED", "0:0:1f8b:GZip:CL_TYPE_ANY:CL_TYPE_GZ", diff -dPNur clamav-0.95.2/libclamav/Makefile.am clamav-0.95.2-ds/libclamav/Makefile.am --- clamav-0.95.2/libclamav/Makefile.am 2009-04-01 13:48:55.000000000 +0200 +++ clamav-0.95.2-ds/libclamav/Makefile.am 2009-09-09 20:11:31.000000000 +0200 @@ -114,7 +114,7 @@ libclamav_internal_utils_nothreads_la_LDFLAGS=-static libclamav_internal_utils_nothreads_la_CFLAGS=-DCL_NOTHREADS -libclamav_la_LIBADD = @LIBLTDL@ $(IFACELIBADD) lzma/liblzma.la libclamav_internal_utils.la @LIBCLAMAV_LIBS@ @THREAD_LIBS@ +libclamav_la_LIBADD = @LIBLTDL@ $(IFACELIBADD) lzma/liblzma.la libclamav_internal_utils.la @LIBCLAMAV_LIBS@ @THREAD_LIBS@ -lun7zip libclamav_la_DEPENDENCIES = @LTDLDEPS@ $(IFACEDEP) libclamav_internal_utils.la libclamav_la_CFLAGS = -DSEARCH_LIBDIR=\"$(libdir)\" libclamav_la_LDFLAGS = @TH_SAFE@ -version-info @LIBCLAMAV_VERSION@ -no-undefined @@ -147,6 +147,8 @@ textdet.h \ filetypes.c \ filetypes.h \ + un7zip.c \ + un7zip.h \ filetypes_int.h \ rtf.c \ rtf.h \ diff -dPNur clamav-0.95.2/libclamav/readdb.c clamav-0.95.2-ds/libclamav/readdb.c --- clamav-0.95.2/libclamav/readdb.c 2009-05-22 14:08:06.000000000 +0200 +++ clamav-0.95.2-ds/libclamav/readdb.c 2009-09-09 20:09:58.000000000 +0200 @@ -1016,6 +1016,9 @@ strncpy(buffer, ftypes_int[line], sizeof(buffer)); buffer[sizeof(buffer)-1]='\0'; } else { + if (line < 1) { + strcpy(buffer, ftypes_int[0]); + } else if(!cli_dbgets(buffer, FILEBUFF, fs, dbio)) break; cli_chomp(buffer); diff -dPNur clamav-0.95.2/libclamav/scanners.c clamav-0.95.2-ds/libclamav/scanners.c --- clamav-0.95.2/libclamav/scanners.c 2009-06-10 17:55:19.000000000 +0200 +++ clamav-0.95.2-ds/libclamav/scanners.c 2009-09-09 20:09:58.000000000 +0200 @@ -97,6 +97,8 @@ #include #endif +#include "un7zip.h" + #if defined(HAVE_READDIR_R_3) || defined(HAVE_READDIR_R_2) #include #include @@ -751,6 +753,41 @@ return ret; } +static int cli_scan7zip(int desc, cli_ctx *ctx) { + const char *tmpdir; + char *dir; + int ret = CL_CLEAN; + + + cli_dbgmsg("in cli_scan7zip()\n"); + + if((tmpdir = getenv("TMPDIR")) == NULL) +#ifdef P_tmpdir + tmpdir = P_tmpdir; +#else + tmpdir = "/tmp"; +#endif + +/* generate temporary directory */ + dir = cli_gentemp(tmpdir); + if(mkdir(dir, 0700)) { + cli_errmsg("7zip: Can't create temporary directory %s\n", dir); + return CL_ETMPDIR; + } + + if((ret = cli_un7zip(dir, desc))) + cli_dbgmsg("7zip: %s\n", cl_strerror(ret)); + else + ret = cli_scandir(dir, ctx, 0); + + if(!ctx->engine->keeptmp) + cli_rmdirs(dir); + + free(dir); + return ret; +} + + static int cli_vba_scandir(const char *dirname, cli_ctx *ctx, struct uniq *U) { int ret = CL_CLEAN, i, j, fd, data_len; @@ -1933,7 +1970,12 @@ if(have_rar && SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_RAR)) ret = cli_scanrar(desc, ctx, 0, NULL); break; - + + case CL_TYPE_7ZIP: + if(SCAN_ARCHIVE) + ret = cli_scan7zip(desc, ctx); + break; + case CL_TYPE_ZIP: if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_ZIP)) ret = cli_unzip(desc, ctx); diff -dPNur clamav-0.95.2/libclamav/un7zip.c clamav-0.95.2-ds/libclamav/un7zip.c --- clamav-0.95.2/libclamav/un7zip.c 1970-01-01 01:00:00.000000000 +0100 +++ clamav-0.95.2-ds/libclamav/un7zip.c 2009-09-09 21:34:50.000000000 +0200 @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2005 McMCC + * + * Support check archives 7zip + * + * 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 2 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +static char const rcsid[] = "$Id: un7zip.c,v 1.0 2005/09/05 01:40:44 mcmcc Exp $"; + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "clamav.h" +#include "others.h" +#include "un7zip.h" +#include "mbox.h" +#include "blob.h" + +int cli_un7zip(const char *dir, int desc) +{ + int fd, s_buff, res; + char buff[4096], uname[48]; + const char *tmpdir; + FILE *out; + + if((tmpdir = getenv("TMPDIR")) == NULL) +#ifdef P_tmpdir + tmpdir = P_tmpdir; +#else + tmpdir = "/tmp"; +#endif + + sprintf(uname, "%s/szpXXXXXX", tmpdir); + + if((fd = mkstemp(uname)) < 0 || (out = fdopen(fd, "w+")) == NULL) + { + + cli_dbgmsg("cli_un7zip: can't generate temporary file %s or open descriptor %d.\n", + uname, fd); + if(fd >= 0) + close(fd); + unlink(uname); + return CL_ETMPFILE; + } + + while((s_buff=read(desc, buff, sizeof(buff))) > 0) + { + if(fwrite(buff, 1, s_buff, out) != s_buff) + { + cli_dbgmsg("cli_un7zip: can't write to file %s.\n", uname); + fclose(out); + close(fd); + unlink(uname); + return CL_EOPEN; + } + } + fclose(out); + close(fd); + + res = un7zip(uname, dir, EXTRACT_7Z); + unlink(uname); + if(res) return CL_EFORMAT; + return CL_CLEAN; +} diff -dPNur clamav-0.95.2/libclamav/un7zip.h clamav-0.95.2-ds/libclamav/un7zip.h --- clamav-0.95.2/libclamav/un7zip.h 1970-01-01 01:00:00.000000000 +0100 +++ clamav-0.95.2-ds/libclamav/un7zip.h 2009-09-09 20:09:58.000000000 +0200 @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2005 McMCC + * + * Support check archives 7zip + * + * 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 2 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +int cli_un7zip(const char *dir, int desc);