integrate CHM unpacker

git-svn: trunk@676
remotes/push_mirror/metadata
Tomasz Kojm 21 years ago
parent 1a24f5592b
commit a5373b6417
  1. 4
      clamav-devel/ChangeLog
  2. 4
      clamav-devel/libclamav/Makefile.am
  3. 15
      clamav-devel/libclamav/Makefile.in
  4. 1078
      clamav-devel/libclamav/chmunpack.c
  5. 26
      clamav-devel/libclamav/chmunpack.h
  6. 1
      clamav-devel/libclamav/filetypes.c
  7. 1
      clamav-devel/libclamav/filetypes.h
  8. 40
      clamav-devel/libclamav/scanners.c

@ -1,3 +1,7 @@
Tue Jul 20 03:26:38 CEST 2004 (tk)
----------------------------------
* libclamav: integrate CHM decoder from Trog
Mon Jul 19 21:24:18 CEST 2004 (tk)
----------------------------------
* libclamav: pe: fix memory leak (Martin Blapp <mb*imp.ch>)

@ -102,6 +102,8 @@ libclamav_la_SOURCES = \
upx.c \
upx.h \
htmlnorm.c \
htmlnorm.h
htmlnorm.h \
chmunpack.c \
chmunpack.h
lib_LTLIBRARIES = libclamav.la

@ -78,15 +78,17 @@ am_libclamav_la_OBJECTS = matcher-ac.lo matcher-bm.lo matcher.lo \
zzip-info.lo zzip-io.lo zzip-stat.lo zzip-zip.lo strc.lo \
blob.lo mbox.lo message.lo snprintf.lo strrcpy.lo table.lo \
text.lo ole2_extract.lo vba_extract.lo msexpand.lo pe.lo \
cabd.lo lzxd.lo mszipd.lo qtmd.lo system.lo upx.lo htmlnorm.lo
cabd.lo lzxd.lo mszipd.lo qtmd.lo system.lo upx.lo htmlnorm.lo \
chmunpack.lo
libclamav_la_OBJECTS = $(am_libclamav_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/blob.Plo ./$(DEPDIR)/cabd.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/cvd.Plo ./$(DEPDIR)/dsig.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/filetypes.Plo ./$(DEPDIR)/htmlnorm.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/lzxd.Plo ./$(DEPDIR)/matcher-ac.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/chmunpack.Plo ./$(DEPDIR)/cvd.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/dsig.Plo ./$(DEPDIR)/filetypes.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/htmlnorm.Plo ./$(DEPDIR)/lzxd.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/matcher-ac.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/matcher-bm.Plo ./$(DEPDIR)/matcher.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/mbox.Plo ./$(DEPDIR)/md5.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/message.Plo ./$(DEPDIR)/msexpand.Plo \
@ -308,7 +310,9 @@ libclamav_la_SOURCES = \
upx.c \
upx.h \
htmlnorm.c \
htmlnorm.h
htmlnorm.h \
chmunpack.c \
chmunpack.h
lib_LTLIBRARIES = libclamav.la
all: all-am
@ -382,6 +386,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/blob.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cabd.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chmunpack.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cvd.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dsig.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filetypes.Plo@am__quote@

File diff suppressed because it is too large Load Diff

@ -0,0 +1,26 @@
/*
* Extract component parts of MS CHM files
*
* Copyright (C) 2004 trog@uncon.org
*
* 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.
*/
#ifndef __CHM_UNPACK_H
#define __CHM_UNPACK_H
int chm_unpack(int fd, const char *dirname);
#endif

@ -58,6 +58,7 @@ static const struct cli_magic_s cli_magic[] = {
{0, "BZh", 3, "BZip", CL_BZFILE},
{0, "SZDD", 4, "compress.exe'd", CL_MSCFILE},
{0, "MSCF", 4, "MS CAB", CL_MSCABFILE},
{0, "ITSF", 4, "MS CHM", CL_MSCHMFILE},
/* Mail */

@ -34,6 +34,7 @@ typedef enum {
CL_MSCFILE,
CL_OLE2FILE,
CL_MSCABFILE,
CL_MSCHMFILE,
/* bigger numbers have higher priority (in o-t-f detection) */
CL_HTMLFILE, /* on the fly */

@ -58,6 +58,7 @@ extern int cli_mbox(const char *dir, int desc); /* FIXME */
#include "ole2_extract.h"
#include "vba_extract.h"
#include "msexpand.h"
#include "chmunpack.h"
#include "pe.h"
#include "filetypes.h"
#include "htmlnorm.h"
@ -906,6 +907,39 @@ static int cli_scanole2(int desc, const char **virname, long int *scanned, const
return ret;
}
static int cli_scanmschm(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, int options, int *arec, int *mrec)
{
const char *tmpdir;
char *tempname;
int ret = CL_CLEAN;
cli_dbgmsg("in cli_scanmschm()\n");
if((tmpdir = getenv("TMPDIR")) == NULL)
#ifdef P_tmpdir
tmpdir = P_tmpdir;
#else
tmpdir = "/tmp";
#endif
tempname = cli_gentemp(tmpdir);
if(mkdir(tempname, 0700)) {
cli_dbgmsg("ScanCHM -> Can't create temporary directory %s\n", tempname);
return CL_ETMPDIR;
}
if(chm_unpack(desc, tempname))
ret = cli_scandir(tempname, virname, scanned, root, limits, options, arec, mrec);
if(!cli_leavetemps_flag)
cli_rmdirs(tempname);
free(tempname);
return ret;
}
static int cli_scanmail(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, int options, int *arec, int *mrec)
{
const char *tmpdir;
@ -983,7 +1017,6 @@ static int cli_magic_scandesc(int desc, const char **virname, long int *scanned,
lseek(desc, 0, SEEK_SET);
if(bread != MAGIC_BUFFER_SIZE) {
cli_dbgmsg("File recognition failed: bread != MAGIC_BUFFER_SIZE (%d != %d)\n", bread, MAGIC_BUFFER_SIZE);
/* short read: No need to do magic */
if((ret = cli_scandesc(desc, virname, scanned, root, 0) == CL_VIRUS))
cli_dbgmsg("%s virus found in descriptor %d.\n", *virname, desc);
@ -1032,6 +1065,11 @@ static int cli_magic_scandesc(int desc, const char **virname, long int *scanned,
ret = cli_scanmail(desc, virname, scanned, root, limits, options, arec, mrec);
break;
case CL_MSCHMFILE:
if(SCAN_ARCHIVE)
ret = cli_scanmschm(desc, virname, scanned, root, limits, options, arec, mrec);
break;
case CL_OLE2FILE:
if(SCAN_OLE2)
ret = cli_scanole2(desc, virname, scanned, root, limits, options, arec, mrec);

Loading…
Cancel
Save