Skip to content

Commit

Permalink
Updating libclamunrar from legacy C implementation to modern unrar 5.…
Browse files Browse the repository at this point in the history
…6.5. API changes and supporting changes included to pass the filepath of the scanned file into libclamav through the cli_ctx structure, required by the unrar library to open archives. The filename argument may be optional for the scandesc scanning variant, but libclamav will make a best effort to identify the filename from the file descriptor if it was not provided. In addition, included the ability to prefix temp file and directory names with file basenames.
  • Loading branch information
micahsnyder committed Oct 19, 2018
1 parent 6c11e82 commit 01eebc1
Show file tree
Hide file tree
Showing 258 changed files with 46,017 additions and 15,833 deletions.
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -11,7 +11,6 @@ libclamav.pc
.libs
libtool
*.l[oa]
Makefile
*.[oa]
platform.h
stamp-h1
Expand Down
2 changes: 1 addition & 1 deletion Makefile.am
Expand Up @@ -19,7 +19,7 @@
ACLOCAL_AMFLAGS=-I m4

SUBDIRS = libltdl libclamav clamscan clamd clamdscan freshclam sigtool clamconf database docs etc clamav-milter test clamdtop clambc unit_tests
EXTRA_DIST = examples shared libclamav.pc.in libclamunrar_iface/Makefile.am libclamunrar_iface/Makefile.in COPYING.bzip2 COPYING.lzma COPYING.unrar COPYING.LGPL COPYING.llvm COPYING.file COPYING.zlib COPYING.getopt COPYING.regex COPYING.YARA COPYING.pcre platform.h.in clamdscan/clamdscan.map win32 libclamav/libmspack-0.5alpha/mspack/mspack.def ChangeLog.md INSTALL.md NEWS.md README.md
EXTRA_DIST = examples shared libclamav.pc.in COPYING.bzip2 COPYING.lzma COPYING.unrar COPYING.LGPL COPYING.llvm COPYING.file COPYING.zlib COPYING.getopt COPYING.regex COPYING.YARA COPYING.pcre platform.h.in libclamunrar libclamunrar_iface clamdscan/clamdscan.map win32 libclamav/libmspack-0.5alpha/mspack/mspack.def ChangeLog.md INSTALL.md NEWS.md README.md

bin_SCRIPTS=clamav-config

Expand Down
17 changes: 11 additions & 6 deletions Makefile.in
Expand Up @@ -117,11 +117,11 @@ DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/docs/man/freshclam.conf.5.in \
$(top_srcdir)/docs/man/sigtool.1.in \
$(top_srcdir)/docs/man/clamdtop.1.in \
$(top_srcdir)/docs/man/clamsubmit.1.in COPYING config/compile \
config/config.guess config/config.rpath config/config.sub \
config/install-sh config/missing config/ylwrap \
config/ltmain.sh $(top_srcdir)/config/compile \
$(top_srcdir)/config/config.guess \
$(top_srcdir)/docs/man/clamsubmit.1.in COPYING config/ar-lib \
config/compile config/config.guess config/config.rpath \
config/config.sub config/install-sh config/missing \
config/ylwrap config/ltmain.sh $(top_srcdir)/config/ar-lib \
$(top_srcdir)/config/compile $(top_srcdir)/config/config.guess \
$(top_srcdir)/config/config.rpath \
$(top_srcdir)/config/config.sub \
$(top_srcdir)/config/install-sh $(top_srcdir)/config/ltmain.sh \
Expand Down Expand Up @@ -386,6 +386,10 @@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CURSES_CPPFLAGS = @CURSES_CPPFLAGS@
CURSES_LIBS = @CURSES_LIBS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DBDIR = @DBDIR@
DEFS = @DEFS@
Expand Down Expand Up @@ -511,6 +515,7 @@ abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
Expand Down Expand Up @@ -572,7 +577,7 @@ ACLOCAL_AMFLAGS = -I m4
SUBDIRS = libltdl libclamav clamscan clamd clamdscan freshclam sigtool \
clamconf database docs etc clamav-milter test clamdtop clambc \
unit_tests $(am__append_1) $(am__append_2)
EXTRA_DIST = examples shared libclamav.pc.in libclamunrar_iface/Makefile.am libclamunrar_iface/Makefile.in COPYING.bzip2 COPYING.lzma COPYING.unrar COPYING.LGPL COPYING.llvm COPYING.file COPYING.zlib COPYING.getopt COPYING.regex COPYING.YARA COPYING.pcre platform.h.in clamdscan/clamdscan.map win32 libclamav/libmspack-0.5alpha/mspack/mspack.def ChangeLog.md INSTALL.md NEWS.md README.md
EXTRA_DIST = examples shared libclamav.pc.in COPYING.bzip2 COPYING.lzma COPYING.unrar COPYING.LGPL COPYING.llvm COPYING.file COPYING.zlib COPYING.getopt COPYING.regex COPYING.YARA COPYING.pcre platform.h.in libclamunrar libclamunrar_iface clamdscan/clamdscan.map win32 libclamav/libmspack-0.5alpha/mspack/mspack.def ChangeLog.md INSTALL.md NEWS.md README.md
bin_SCRIPTS = clamav-config
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libclamav.pc
Expand Down
60 changes: 60 additions & 0 deletions aclocal.m4
Expand Up @@ -216,6 +216,66 @@ m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])

# Copyright (C) 2011-2013 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# AM_PROG_AR([ACT-IF-FAIL])
# -------------------------
# Try to determine the archiver interface, and trigger the ar-lib wrapper
# if it is needed. If the detection of archiver interface fails, run
# ACT-IF-FAIL (default is to abort configure with a proper error message).
AC_DEFUN([AM_PROG_AR],
[AC_BEFORE([$0], [LT_INIT])dnl
AC_BEFORE([$0], [AC_PROG_LIBTOOL])dnl
AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
AC_REQUIRE_AUX_FILE([ar-lib])dnl
AC_CHECK_TOOLS([AR], [ar lib "link -lib"], [false])
: ${AR=ar}
AC_CACHE_CHECK([the archiver ($AR) interface], [am_cv_ar_interface],
[AC_LANG_PUSH([C])
am_cv_ar_interface=ar
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int some_variable = 0;]])],
[am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
AC_TRY_EVAL([am_ar_try])
if test "$ac_status" -eq 0; then
am_cv_ar_interface=ar
else
am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
AC_TRY_EVAL([am_ar_try])
if test "$ac_status" -eq 0; then
am_cv_ar_interface=lib
else
am_cv_ar_interface=unknown
fi
fi
rm -f conftest.lib libconftest.a
])
AC_LANG_POP([C])])
case $am_cv_ar_interface in
ar)
;;
lib)
# Microsoft lib, so override with the ar-lib wrapper script.
# FIXME: It is wrong to rewrite AR.
# But if we don't then we get into trouble of one sort or another.
# A longer-term fix would be to have automake use am__AR in this case,
# and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something
# similar.
AR="$am_aux_dir/ar-lib $AR"
;;
unknown)
m4_default([$1],
[AC_MSG_ERROR([could not determine $AR interface])])
;;
esac
AC_SUBST([AR])dnl
])

# AM_AUX_DIR_EXPAND -*- Autoconf -*-

# Copyright (C) 2001-2013 Free Software Foundation, Inc.
Expand Down
5 changes: 5 additions & 0 deletions clamav-milter/Makefile.in
Expand Up @@ -341,6 +341,10 @@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CURSES_CPPFLAGS = @CURSES_CPPFLAGS@
CURSES_LIBS = @CURSES_LIBS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DBDIR = @DBDIR@
DEFS = @DEFS@ -DCL_NOLIBCLAMAV
Expand Down Expand Up @@ -466,6 +470,7 @@ abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
Expand Down
5 changes: 5 additions & 0 deletions clambc/Makefile.in
Expand Up @@ -277,6 +277,10 @@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CURSES_CPPFLAGS = @CURSES_CPPFLAGS@
CURSES_LIBS = @CURSES_LIBS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DBDIR = @DBDIR@
DEFS = @DEFS@
Expand Down Expand Up @@ -402,6 +406,7 @@ abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
Expand Down
5 changes: 5 additions & 0 deletions clamconf/Makefile.in
Expand Up @@ -295,6 +295,10 @@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CURSES_CPPFLAGS = @CURSES_CPPFLAGS@
CURSES_LIBS = @CURSES_LIBS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DBDIR = @DBDIR@
DEFS = @DEFS@ -DCL_NOTHREADS
Expand Down Expand Up @@ -420,6 +424,7 @@ abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
Expand Down
5 changes: 5 additions & 0 deletions clamd/Makefile.in
Expand Up @@ -352,6 +352,10 @@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CURSES_CPPFLAGS = @CURSES_CPPFLAGS@
CURSES_LIBS = @CURSES_LIBS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DBDIR = @DBDIR@
DEFS = @DEFS@
Expand Down Expand Up @@ -477,6 +481,7 @@ abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
Expand Down
2 changes: 1 addition & 1 deletion clamd/onaccess_fan.c
Expand Up @@ -359,7 +359,7 @@ static int cauth_scanfile(const char *fname, int extinfo, struct thrarg *tharg)
if(fd == -1)
return -1;

if(cl_scandesc_callback(fd, &virname, NULL, tharg->engine, tharg->options, &context) == CL_VIRUS) {
if(cl_scandesc_callback(fd, fname, &virname, NULL, tharg->engine, tharg->options, &context) == CL_VIRUS) {
if(extinfo && context.virsize)
logg("ScanOnAccess: %s: %s(%s:%llu) FOUND\n", fname, virname, context.virhash, context.virsize);
else
Expand Down
2 changes: 1 addition & 1 deletion clamd/onaccess_others.c
Expand Up @@ -105,7 +105,7 @@ int onas_scan(const char *fname, int fd, const char **virname, const struct cl_e
context.virsize = 0;
context.scandata = NULL;

ret = cl_scandesc_callback(fd, virname, NULL, engine, options, &context);
ret = cl_scandesc_callback(fd, fname, virname, NULL, engine, options, &context);

if (ret) {
if (extinfo && context.virsize)
Expand Down
2 changes: 1 addition & 1 deletion clamd/onaccess_scth.c
Expand Up @@ -36,7 +36,7 @@

#include "others.h"
#include "priv_fts.h"

#include "onaccess_others.h"
#include "onaccess_scth.h"
#include "onaccess_others.h"

Expand Down
18 changes: 9 additions & 9 deletions clamd/scanner.c
Expand Up @@ -393,8 +393,8 @@ int scanfd(
thrmgr_setactivetask(fdstr, NULL);
context.filename = fdstr;
context.virsize = 0;
context.scandata = NULL;
ret = cl_scandesc_callback(fd, &virname, scanned, engine, options, &context);
context.scandata = NULL;
ret = cl_scandesc_callback(fd, NULL, &virname, scanned, engine, options, &context);
thrmgr_setactivetask(NULL, NULL);

if (thrmgr_group_need_terminate(conn->group)) {
Expand Down Expand Up @@ -563,13 +563,13 @@ int scanstream(
}

if(retval == 1) {
lseek(tmpd, 0, SEEK_SET);
thrmgr_setactivetask(peer_addr, NULL);
context.filename = peer_addr;
context.virsize = 0;
context.scandata = NULL;
ret = cl_scandesc_callback(tmpd, &virname, scanned, engine, options, &context);
thrmgr_setactivetask(NULL, NULL);
lseek(tmpd, 0, SEEK_SET);
thrmgr_setactivetask(peer_addr, NULL);
context.filename = peer_addr;
context.virsize = 0;
context.scandata = NULL;
ret = cl_scandesc_callback(tmpd, NULL, &virname, scanned, engine, options, &context);
thrmgr_setactivetask(NULL, NULL);
} else {
ret = -1;
}
Expand Down
5 changes: 5 additions & 0 deletions clamdscan/Makefile.in
Expand Up @@ -306,6 +306,10 @@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CURSES_CPPFLAGS = @CURSES_CPPFLAGS@
CURSES_LIBS = @CURSES_LIBS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DBDIR = @DBDIR@
DEFS = @DEFS@ -DCL_NOTHREADS -DCL_NOLIBCLAMAV
Expand Down Expand Up @@ -431,6 +435,7 @@ abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
Expand Down
5 changes: 5 additions & 0 deletions clamdtop/Makefile.in
Expand Up @@ -312,6 +312,10 @@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CURSES_CPPFLAGS = @CURSES_CPPFLAGS@
CURSES_LIBS = @CURSES_LIBS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DBDIR = @DBDIR@
DEFS = @DEFS@ -DCL_NOTHREADS -DCL_NOLIBCLAMAV
Expand Down Expand Up @@ -437,6 +441,7 @@ abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
Expand Down
5 changes: 5 additions & 0 deletions clamscan/Makefile.in
Expand Up @@ -297,6 +297,10 @@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CURSES_CPPFLAGS = @CURSES_CPPFLAGS@
CURSES_LIBS = @CURSES_LIBS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DBDIR = @DBDIR@
DEFS = @DEFS@ -DCL_NOTHREADS
Expand Down Expand Up @@ -422,6 +426,7 @@ abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
Expand Down
4 changes: 2 additions & 2 deletions clamscan/clamscan.c
Expand Up @@ -68,8 +68,8 @@ int main(int argc, char **argv)
struct optstruct *opts;
const struct optstruct *opt;

if(check_flevel())
exit(2);
if (check_flevel())
exit(2);

#if !defined(_WIN32) && !defined(C_BEOS)
sigemptyset(&sigset);
Expand Down
2 changes: 1 addition & 1 deletion clamscan/manager.c
Expand Up @@ -389,7 +389,7 @@ static void scanfile(const char *filename, struct cl_engine *engine, const struc

data.chain = &chain;
data.filename = filename;
if((ret = cl_scandesc_callback(fd, &virname, &info.blocks, engine, options, &data)) == CL_VIRUS) {
if((ret = cl_scandesc_callback(fd, filename, &virname, &info.blocks, engine, options, &data)) == CL_VIRUS) {
if(optget(opts, "archive-verbose")->enabled) {
if (chain.nchains > 1) {
char str[128];
Expand Down
5 changes: 5 additions & 0 deletions clamsubmit/Makefile.in
Expand Up @@ -295,6 +295,10 @@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CURSES_CPPFLAGS = @CURSES_CPPFLAGS@
CURSES_LIBS = @CURSES_LIBS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DBDIR = @DBDIR@
DEFS = @DEFS@ -DCL_NOTHREADS
Expand Down Expand Up @@ -420,6 +424,7 @@ abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
Expand Down

0 comments on commit 01eebc1

Please sign in to comment.