mirror of
https://github.com/Cisco-Talos/clamav.git
synced 2025-10-19 10:23:17 +00:00
Add some performance measurement code.
Default off, activated by --dev-performance, and always on in c4w.
This commit is contained in:
parent
0796f1cab5
commit
63feb6cdf4
16 changed files with 262 additions and 14 deletions
|
@ -383,6 +383,9 @@
|
|||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/times.h> header file. */
|
||||
#undef HAVE_SYS_TIMES_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
|
|
|
@ -630,6 +630,9 @@ int scanmanager(const struct optstruct *opts)
|
|||
options |= CL_SCAN_INTERNAL_COLLECT_SHA;
|
||||
#endif
|
||||
|
||||
if(optget(opts, "dev-performance")->enabled)
|
||||
options |= CL_SCAN_PERFORMANCE_INFO;
|
||||
|
||||
if(optget(opts, "detect-structured")->enabled) {
|
||||
options |= CL_SCAN_STRUCTURED;
|
||||
|
||||
|
|
2
configure
vendored
2
configure
vendored
|
@ -13341,7 +13341,7 @@ GPERF=${GPERF-"${am_missing_run}gperf"}
|
|||
|
||||
|
||||
|
||||
for ac_header in stdint.h unistd.h sys/int_types.h dlfcn.h inttypes.h sys/inttypes.h memory.h ndir.h stdlib.h strings.h string.h sys/mman.h sys/param.h sys/stat.h sys/types.h malloc.h poll.h limits.h sys/filio.h sys/uio.h termios.h stdbool.h pwd.h grp.h
|
||||
for ac_header in stdint.h unistd.h sys/int_types.h dlfcn.h inttypes.h sys/inttypes.h sys/times.h memory.h ndir.h stdlib.h strings.h string.h sys/mman.h sys/param.h sys/stat.h sys/types.h malloc.h poll.h limits.h sys/filio.h sys/uio.h termios.h stdbool.h pwd.h grp.h
|
||||
do :
|
||||
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
||||
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
|
||||
|
|
|
@ -408,7 +408,7 @@ AM_CONDITIONAL([VERSIONSCRIPT], test "x$ac_cv_ld_version_script" = "xyes")
|
|||
AM_MISSING_PROG(GPERF, gperf)
|
||||
AC_SUBST(GPERF)
|
||||
|
||||
AC_CHECK_HEADERS([stdint.h unistd.h sys/int_types.h dlfcn.h inttypes.h sys/inttypes.h memory.h ndir.h stdlib.h strings.h string.h sys/mman.h sys/param.h sys/stat.h sys/types.h malloc.h poll.h limits.h sys/filio.h sys/uio.h termios.h stdbool.h pwd.h grp.h])
|
||||
AC_CHECK_HEADERS([stdint.h unistd.h sys/int_types.h dlfcn.h inttypes.h sys/inttypes.h sys/times.h memory.h ndir.h stdlib.h strings.h string.h sys/mman.h sys/param.h sys/stat.h sys/types.h malloc.h poll.h limits.h sys/filio.h sys/uio.h termios.h stdbool.h pwd.h grp.h])
|
||||
AC_CHECK_HEADER([syslog.h],AC_DEFINE([USE_SYSLOG],1,[use syslog]),)
|
||||
|
||||
AC_TYPE_OFF_T
|
||||
|
|
|
@ -68,7 +68,7 @@ target_triplet = @target@
|
|||
|
||||
subdir = libclamav
|
||||
DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \
|
||||
$(srcdir)/Makefile.in
|
||||
$(srcdir)/Makefile.in COPYING
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
|
||||
$(top_srcdir)/m4/argz.m4 \
|
||||
|
|
|
@ -1624,6 +1624,8 @@ int cli_bytecode_run(const struct cli_all_bc *bcs, const struct cli_bc *bc, stru
|
|||
cli_dbgmsg("bytecode triggered but running bytecodes is disabled\n");
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
if (cctx)
|
||||
cli_event_time_start(cctx->perf, PERFT_BYTECODE);
|
||||
ctx->env = &bcs->env;
|
||||
context_safe(ctx);
|
||||
if (test_mode) {
|
||||
|
@ -1736,6 +1738,8 @@ int cli_bytecode_run(const struct cli_all_bc *bcs, const struct cli_bc *bc, stru
|
|||
}
|
||||
cli_events_free(jit_ev);
|
||||
cli_events_free(interp_ev);
|
||||
if (cctx)
|
||||
cli_event_time_stop(cctx->perf, PERFT_BYTECODE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -119,6 +119,7 @@ typedef enum {
|
|||
#define CL_SCAN_HEURISTIC_PRECEDENCE 0x80000
|
||||
#define CL_SCAN_BLOCKMACROS 0x100000
|
||||
|
||||
#define CL_SCAN_PERFORMANCE_INFO 0x40000000 /* collect performance timings */
|
||||
#define CL_SCAN_INTERNAL_COLLECT_SHA 0x80000000 /* Enables hash output in sha-collect builds - for internal use only */
|
||||
|
||||
/* recommended scan settings */
|
||||
|
|
|
@ -150,8 +150,10 @@ void cli_event_int(cli_events_t *ctx, unsigned id, uint64_t arg)
|
|||
switch (ev->multiple) {
|
||||
case multiple_last:
|
||||
ev->u.v_int = arg;
|
||||
ev->count++;
|
||||
break;
|
||||
case multiple_sum:
|
||||
ev->count++;
|
||||
ev->u.v_int += arg;
|
||||
break;
|
||||
case multiple_chain:
|
||||
|
@ -176,6 +178,24 @@ void cli_event_time_start(cli_events_t *ctx, unsigned id)
|
|||
}
|
||||
gettimeofday(&tv, NULL);
|
||||
ev->u.v_int -= ((int64_t)tv.tv_sec * 1000000) + tv.tv_usec;
|
||||
ev->count++;
|
||||
}
|
||||
|
||||
void cli_event_time_nested_start(cli_events_t *ctx, unsigned id, unsigned nestedid)
|
||||
{
|
||||
struct timeval tv;
|
||||
struct cli_event *ev = get_event(ctx, id);
|
||||
struct cli_event *evnested = get_event(ctx, nestedid);
|
||||
if (!ev || !evnested)
|
||||
return;
|
||||
if (ev->type != ev_time || evnested->type != ev_time) {
|
||||
cli_event_error_str(ctx, "cli_event_time* must be called with ev_time type");
|
||||
return;
|
||||
}
|
||||
gettimeofday(&tv, NULL);
|
||||
ev->u.v_int -= ((int64_t)tv.tv_sec * 1000000) + tv.tv_usec;
|
||||
ev->u.v_int += evnested->u.v_int;
|
||||
ev->count++;
|
||||
}
|
||||
|
||||
void cli_event_time_stop(cli_events_t *ctx, unsigned id)
|
||||
|
@ -192,6 +212,22 @@ void cli_event_time_stop(cli_events_t *ctx, unsigned id)
|
|||
ev->u.v_int += ((int64_t)tv.tv_sec * 1000000) + tv.tv_usec;
|
||||
}
|
||||
|
||||
void cli_event_time_nested_stop(cli_events_t *ctx, unsigned id, unsigned nestedid)
|
||||
{
|
||||
struct timeval tv;
|
||||
struct cli_event *ev = get_event(ctx, id);
|
||||
struct cli_event *evnested = get_event(ctx, nestedid);
|
||||
if (!ev || !evnested)
|
||||
return;
|
||||
if (ev->type != ev_time || evnested->type != ev_time) {
|
||||
cli_event_error_str(ctx, "cli_event_time* must be called with ev_time type");
|
||||
return;
|
||||
}
|
||||
gettimeofday(&tv, NULL);
|
||||
ev->u.v_int += ((int64_t)tv.tv_sec * 1000000) + tv.tv_usec;
|
||||
ev->u.v_int -= evnested->u.v_int;
|
||||
}
|
||||
|
||||
static void event_string(cli_events_t *ctx, struct cli_event *ev, const char *str)
|
||||
{
|
||||
if (!str)
|
||||
|
|
|
@ -74,7 +74,8 @@ void cli_event_data(cli_events_t *ctx, unsigned id, const void* data, uint32_t l
|
|||
void cli_event_fastdata(cli_events_t *ctx, unsigned id, const void *data, uint32_t len);
|
||||
|
||||
void cli_event_time_start(cli_events_t *ctx, unsigned id);
|
||||
void cli_event_time_stop(cli_events_t *ctx, unsigned id);
|
||||
void cli_event_time_nested_start(cli_events_t *ctx, unsigned id, unsigned nestedid);
|
||||
void cli_event_time_nested_stop(cli_events_t *ctx, unsigned id, unsigned nestedid);
|
||||
|
||||
/* event_count is implemented as ev_int, with ev_multiple_sum multiple */
|
||||
void cli_event_count(cli_events_t *ctx, unsigned id);
|
||||
|
@ -99,4 +100,22 @@ int cli_event_diff_all(cli_events_t *ctx1, cli_events_t *ctx2, compare_filter_t
|
|||
/* returns whether the given context had errors */
|
||||
int cli_event_errors(cli_events_t *ctx);
|
||||
|
||||
enum perfev {
|
||||
PERFT_SCAN,
|
||||
PERFT_PRECB,
|
||||
PERFT_POSTCB,
|
||||
PERFT_CACHE,
|
||||
PERFT_FT,
|
||||
PERFT_CONTAINER,
|
||||
PERFT_SCRIPT,
|
||||
PERFT_PE,
|
||||
PERFT_RAW,
|
||||
PERFT_RAWTYPENO,
|
||||
PERFT_MAP,
|
||||
PERFT_BYTECODE,
|
||||
PERFT_KTIME,
|
||||
PERFT_UTIME,
|
||||
PERFT_LAST
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "regex/regex.h"
|
||||
#include "bytecode.h"
|
||||
#include "bytecode_api.h"
|
||||
#include "events.h"
|
||||
|
||||
/*
|
||||
* CL_FLEVEL is the signature f-level specific to the current code and
|
||||
|
@ -125,6 +126,7 @@ typedef struct cli_ctx_tag {
|
|||
fmap_t **fmap;
|
||||
bitset_t* hook_lsig_matches;
|
||||
void *cb_ctx;
|
||||
cli_events_t* perf;
|
||||
#ifdef HAVE__INTERNAL__SHA_COLLECT
|
||||
char entry_filename[2048];
|
||||
int sha_collect;
|
||||
|
|
|
@ -39,6 +39,9 @@
|
|||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#ifdef HAVE_SYS_TIMES_H
|
||||
#include <sys/times.h>
|
||||
#endif
|
||||
|
||||
#define DCONF_ARCH ctx->dconf->archive
|
||||
#define DCONF_DOC ctx->dconf->doc
|
||||
|
@ -1723,6 +1726,150 @@ static int cli_scanembpe(cli_ctx *ctx, off_t offset)
|
|||
return CL_CLEAN;
|
||||
}
|
||||
|
||||
|
||||
#if defined(_WIN32) || defined(C_LINUX)
|
||||
#define PERF_MEASURE
|
||||
#endif
|
||||
|
||||
#ifdef PERF_MEASURE
|
||||
|
||||
static struct {
|
||||
enum perfev id;
|
||||
const char *name;
|
||||
enum ev_type type;
|
||||
} perf_events[] = {
|
||||
{PERFT_SCAN, "full scan", ev_time},
|
||||
{PERFT_PRECB, "prescan cb", ev_time},
|
||||
{PERFT_POSTCB, "postscan cb", ev_time},
|
||||
{PERFT_CACHE, "cache", ev_time},
|
||||
{PERFT_FT, "filetype", ev_time},
|
||||
{PERFT_CONTAINER, "container", ev_time},
|
||||
{PERFT_SCRIPT, "script", ev_time},
|
||||
{PERFT_PE, "pe", ev_time},
|
||||
{PERFT_RAW, "raw", ev_time},
|
||||
{PERFT_RAWTYPENO, "raw container", ev_time},
|
||||
{PERFT_MAP, "map", ev_time},
|
||||
{PERFT_BYTECODE,"bytecode", ev_time},
|
||||
{PERFT_KTIME,"kernel", ev_int},
|
||||
{PERFT_UTIME,"user", ev_int}
|
||||
};
|
||||
|
||||
static void get_thread_times(uint64_t *kt, uint64_t *ut)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
LPFILETIME c,e,k,u;
|
||||
ULARGE_INTEGER kl,ul;
|
||||
if (!GetThreadTimes(GetCurrentThread(), &c, &e, &k, &u)) {
|
||||
*kt = *ut = 0;
|
||||
return;
|
||||
}
|
||||
kl.LowPart = k.dwLowDateTime;
|
||||
kl.HighPart = k.dwHighDateTime;
|
||||
ul.LowPart = u.dwLowDateTime;
|
||||
ul.HighPart = u.dwHighDateTime;
|
||||
*kt = kl.QuadPart / 10;
|
||||
*ut = ul.QuadPart / 10;
|
||||
#else
|
||||
struct tms tbuf;
|
||||
if (times(&tbuf) != -1) {
|
||||
clock_t tck = sysconf(_SC_CLK_TCK);
|
||||
*kt = 1000000*tbuf.tms_stime / tck;
|
||||
*ut = 1000000*tbuf.tms_utime / tck;
|
||||
} else {
|
||||
*kt = *ut = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void perf_init(cli_ctx *ctx)
|
||||
{
|
||||
uint64_t kt,ut;
|
||||
unsigned i;
|
||||
|
||||
if (!(ctx->options & CL_SCAN_PERFORMANCE_INFO))
|
||||
return;
|
||||
|
||||
ctx->perf = cli_events_new(PERFT_LAST);
|
||||
for (i=0;i<sizeof(perf_events)/sizeof(perf_events[0]);i++) {
|
||||
if (cli_event_define(ctx->perf, perf_events[i].id, perf_events[i].name,
|
||||
perf_events[i].type, multiple_sum) == -1)
|
||||
continue;
|
||||
}
|
||||
cli_event_time_start(ctx->perf, PERFT_SCAN);
|
||||
get_thread_times(&kt, &ut);
|
||||
cli_event_int(ctx->perf, PERFT_KTIME, -kt);
|
||||
cli_event_int(ctx->perf, PERFT_UTIME, -ut);
|
||||
}
|
||||
|
||||
static inline void perf_done(cli_ctx* ctx)
|
||||
{
|
||||
char timestr[512];
|
||||
char *p;
|
||||
unsigned i;
|
||||
uint64_t kt,ut;
|
||||
cli_events_t *perf = ctx->perf;
|
||||
|
||||
if (!perf)
|
||||
return;
|
||||
|
||||
p = timestr;
|
||||
char *pend = timestr + sizeof(timestr) - 1;
|
||||
*pend = 0;
|
||||
|
||||
cli_event_time_stop(perf, PERFT_SCAN);
|
||||
get_thread_times(&kt, &ut);
|
||||
cli_event_int(perf, PERFT_KTIME, kt);
|
||||
cli_event_int(perf, PERFT_UTIME, ut);
|
||||
|
||||
for (i=0;i<sizeof(perf_events)/sizeof(perf_events[0]);i++) {
|
||||
union ev_val val;
|
||||
unsigned count;
|
||||
|
||||
cli_event_get(perf, perf_events[i].id, &val, &count);
|
||||
if (p < pend)
|
||||
p += snprintf(p, pend - p, "%s: %d.%03ums, ", perf_events[i].name,
|
||||
(signed)(val.v_int / 1000),
|
||||
(unsigned)(val.v_int % 1000));
|
||||
}
|
||||
*p = 0;
|
||||
cli_infomsg(ctx, "performance: %s\n", timestr);
|
||||
|
||||
|
||||
cli_events_free(perf);
|
||||
ctx->perf = NULL;
|
||||
}
|
||||
|
||||
static inline void perf_start(cli_ctx* ctx, int id)
|
||||
{
|
||||
cli_event_time_start(ctx->perf, id);
|
||||
}
|
||||
|
||||
static inline void perf_stop(cli_ctx* ctx, int id)
|
||||
{
|
||||
cli_event_time_stop(ctx->perf, id);
|
||||
}
|
||||
|
||||
static inline void perf_nested_start(cli_ctx* ctx, int id, int nestedid)
|
||||
{
|
||||
cli_event_time_nested_start(ctx->perf, id, nestedid);
|
||||
}
|
||||
|
||||
static inline void perf_nested_stop(cli_ctx* ctx, int id, int nestedid)
|
||||
{
|
||||
cli_event_time_nested_stop(ctx->perf, id, nestedid);
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
static inline void perf_init(cli_events_t **perf) {}
|
||||
static inline void perf_start(cli_ctx* ctx, int id){}
|
||||
static inline void perf_stop(cli_ctx* ctx, int id){}
|
||||
static inline void perf_nested_start(cli_ctx* ctx, int id){}
|
||||
static inline void perf_nested_stop(cli_ctx* ctx, int id){}
|
||||
static inline void perf_done(cli_events_t **perf) {}
|
||||
#endif
|
||||
|
||||
|
||||
static int cli_scanraw(cli_ctx *ctx, cli_file_t type, uint8_t typercg, cli_file_t *dettype, unsigned char *refhash)
|
||||
{
|
||||
int ret = CL_CLEAN, nret = CL_CLEAN;
|
||||
|
@ -1738,12 +1885,15 @@ static int cli_scanraw(cli_ctx *ctx, cli_file_t type, uint8_t typercg, cli_file_
|
|||
if(ctx->engine->maxreclevel && ctx->recursion >= ctx->engine->maxreclevel)
|
||||
return CL_EMAXREC;
|
||||
|
||||
perf_start(ctx, PERFT_RAW);
|
||||
if(typercg)
|
||||
acmode |= AC_SCAN_FT;
|
||||
|
||||
ret = cli_fmap_scandesc(ctx, type == CL_TYPE_TEXT_ASCII ? 0 : type, 0, &ftoffset, acmode, NULL, refhash);
|
||||
perf_stop(ctx, PERFT_RAW);
|
||||
|
||||
if(ret >= CL_TYPENO) {
|
||||
perf_nested_start(ctx, PERFT_RAWTYPENO, PERFT_SCAN);
|
||||
ctx->recursion++;
|
||||
if(nret != CL_VIRUS) {
|
||||
lastzip = lastrar = 0xdeadbeef;
|
||||
|
@ -1880,6 +2030,7 @@ static int cli_scanraw(cli_ctx *ctx, cli_file_t type, uint8_t typercg, cli_file_
|
|||
default:
|
||||
break;
|
||||
}
|
||||
perf_nested_stop(ctx, PERFT_RAWTYPENO, PERFT_SCAN);
|
||||
ctx->recursion--;
|
||||
ret = nret;
|
||||
}
|
||||
|
@ -1915,20 +2066,24 @@ static void emax_reached(cli_ctx *ctx) {
|
|||
#define ret_from_magicscan(retcode) do { \
|
||||
cli_dbgmsg("cli_magic_scandesc: returning %d %s\n", retcode, __AT__); \
|
||||
if(ctx->engine->cb_post_scan) { \
|
||||
perf_start(ctx, PERFT_POSTCB); \
|
||||
switch(ctx->engine->cb_post_scan(desc, retcode, retcode == CL_VIRUS && ctx->virname ? *ctx->virname : NULL, ctx->cb_ctx)) { \
|
||||
case CL_BREAK: \
|
||||
cli_dbgmsg("cli_magic_scandesc: file whitelisted by callback\n"); \
|
||||
perf_stop(ctx, PERFT_POSTCB); \
|
||||
return CL_CLEAN; \
|
||||
case CL_VIRUS: \
|
||||
cli_dbgmsg("cli_magic_scandesc: file blacklisted by callback\n"); \
|
||||
if(ctx->virname) \
|
||||
*ctx->virname = "Detected.By.Callback"; \
|
||||
perf_stop(ctx, PERFT_POSTCB); \
|
||||
return CL_VIRUS; \
|
||||
case CL_CLEAN: \
|
||||
break; \
|
||||
default: \
|
||||
cli_warnmsg("cli_magic_scandesc: ignoring bad return code from callback\n"); \
|
||||
} \
|
||||
perf_stop(ctx, PERFT_POSTCB); \
|
||||
}\
|
||||
return retcode; \
|
||||
} while(0)
|
||||
|
@ -1981,18 +2136,23 @@ static int magic_scandesc(int desc, cli_ctx *ctx, cli_file_t type)
|
|||
}
|
||||
|
||||
ctx->fmap++;
|
||||
perf_start(ctx, PERFT_MAP);
|
||||
if(!(*ctx->fmap = fmap(desc, 0, sb.st_size))) {
|
||||
cli_errmsg("CRITICAL: fmap() failed\n");
|
||||
ctx->fmap--;
|
||||
perf_stop(ctx, PERFT_MAP);
|
||||
ret_from_magicscan(CL_EMEM);
|
||||
}
|
||||
perf_stop(ctx, PERFT_MAP);
|
||||
|
||||
if(ctx->engine->cb_pre_scan) {
|
||||
perf_start(ctx, PERFT_PRECB);
|
||||
switch(ctx->engine->cb_pre_scan(desc, ctx->cb_ctx)) {
|
||||
case CL_BREAK:
|
||||
cli_dbgmsg("cli_magic_scandesc: file whitelisted by callback\n");
|
||||
funmap(*ctx->fmap);
|
||||
ctx->fmap--;
|
||||
perf_stop(ctx, PERFT_PRECB);
|
||||
ret_from_magicscan(CL_CLEAN);
|
||||
case CL_VIRUS:
|
||||
cli_dbgmsg("cli_magic_scandesc: file blacklisted by callback\n");
|
||||
|
@ -2000,19 +2160,24 @@ static int magic_scandesc(int desc, cli_ctx *ctx, cli_file_t type)
|
|||
*ctx->virname = "Detected.By.Callback";
|
||||
funmap(*ctx->fmap);
|
||||
ctx->fmap--;
|
||||
perf_stop(ctx, PERFT_PRECB);
|
||||
ret_from_magicscan(CL_VIRUS);
|
||||
case CL_CLEAN:
|
||||
break;
|
||||
default:
|
||||
cli_warnmsg("cli_magic_scandesc: ignoring bad return code from callback\n");
|
||||
}
|
||||
perf_stop(ctx, PERFT_PRECB);
|
||||
}
|
||||
|
||||
perf_start(ctx, PERFT_CACHE);
|
||||
if(cache_check(hash, ctx) == CL_CLEAN) {
|
||||
funmap(*ctx->fmap);
|
||||
ctx->fmap--;
|
||||
perf_stop(ctx, PERFT_CACHE);
|
||||
ret_from_magicscan(CL_CLEAN);
|
||||
}
|
||||
perf_stop(ctx, PERFT_CACHE);
|
||||
hashed_size = (*ctx->fmap)->len;
|
||||
old_hook_lsig_matches = ctx->hook_lsig_matches;
|
||||
ctx->hook_lsig_matches = NULL;
|
||||
|
@ -2038,8 +2203,10 @@ static int magic_scandesc(int desc, cli_ctx *ctx, cli_file_t type)
|
|||
ret_from_magicscan(ret);
|
||||
}
|
||||
|
||||
perf_start(ctx, PERFT_FT);
|
||||
if(type == CL_TYPE_ANY)
|
||||
type = cli_filetype2(*ctx->fmap, ctx->engine); /* FIXMEFMAP: port to fmap */
|
||||
perf_stop(ctx, PERFT_FT);
|
||||
if(type == CL_TYPE_ERROR) {
|
||||
cli_dbgmsg("cli_magic_scandesc: cli_filetype2 returned CL_TYPE_ERROR\n");
|
||||
funmap(*ctx->fmap);
|
||||
|
@ -2073,6 +2240,7 @@ static int magic_scandesc(int desc, cli_ctx *ctx, cli_file_t type)
|
|||
}
|
||||
|
||||
ctx->recursion++;
|
||||
perf_nested_start(ctx, PERFT_CONTAINER, PERFT_SCAN);
|
||||
switch(type) {
|
||||
case CL_TYPE_IGNORED:
|
||||
break;
|
||||
|
@ -2306,6 +2474,7 @@ static int magic_scandesc(int desc, cli_ctx *ctx, cli_file_t type)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
perf_nested_stop(ctx, PERFT_CONTAINER, PERFT_SCAN);
|
||||
ctx->recursion--;
|
||||
ctx->container_type = current_container_type;
|
||||
ctx->container_size = current_container_size;
|
||||
|
@ -2347,22 +2516,26 @@ static int magic_scandesc(int desc, cli_ctx *ctx, cli_file_t type)
|
|||
case CL_TYPE_TEXT_UTF16BE:
|
||||
case CL_TYPE_TEXT_UTF16LE:
|
||||
case CL_TYPE_TEXT_UTF8:
|
||||
perf_nested_start(ctx, PERFT_SCRIPT, PERFT_SCAN);
|
||||
if((DCONF_DOC & DOC_CONF_SCRIPT) && dettype != CL_TYPE_HTML)
|
||||
ret = cli_scanscript(ctx);
|
||||
if(SCAN_MAIL && (DCONF_MAIL & MAIL_CONF_MBOX) && ret != CL_VIRUS && (ctx->container_type == CL_TYPE_MAIL || dettype == CL_TYPE_MAIL)) {
|
||||
lseek(desc, 0, SEEK_SET);
|
||||
ret = cli_scandesc(desc, ctx, CL_TYPE_MAIL, 0, NULL, AC_SCAN_VIR, NULL);
|
||||
}
|
||||
perf_nested_stop(ctx, PERFT_SCRIPT, PERFT_SCAN);
|
||||
break;
|
||||
/* Due to performance reasons all executables were first scanned
|
||||
* in raw mode. Now we will try to unpack them
|
||||
*/
|
||||
case CL_TYPE_MSEXE:
|
||||
perf_nested_start(ctx, PERFT_PE, PERFT_SCAN);
|
||||
if(SCAN_PE && ctx->dconf->pe) {
|
||||
unsigned int corrupted_input = ctx->corrupted_input;
|
||||
ret = cli_scanpe(ctx);
|
||||
ctx->corrupted_input = corrupted_input;
|
||||
}
|
||||
perf_nested_stop(ctx, PERFT_PE, PERFT_SCAN);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -2383,7 +2556,9 @@ static int magic_scandesc(int desc, cli_ctx *ctx, cli_file_t type)
|
|||
case CL_EMAXFILES:
|
||||
cli_dbgmsg("Descriptor[%d]: %s\n", desc, cl_strerror(ret));
|
||||
case CL_CLEAN:
|
||||
perf_start(ctx, PERFT_CACHE);
|
||||
cache_add(hash, hashed_size, ctx);
|
||||
perf_stop(ctx, PERFT_CACHE);
|
||||
ret_from_magicscan(CL_CLEAN);
|
||||
default:
|
||||
ret_from_magicscan(ret);
|
||||
|
@ -2427,6 +2602,7 @@ int cl_scandesc_callback(int desc, const char **virname, unsigned long int *scan
|
|||
free(ctx.fmap);
|
||||
return CL_EMEM;
|
||||
}
|
||||
perf_init(&ctx);
|
||||
|
||||
#ifdef HAVE__INTERNAL__SHA_COLLECT
|
||||
if(scanoptions & CL_SCAN_INTERNAL_COLLECT_SHA) {
|
||||
|
@ -2451,6 +2627,7 @@ int cl_scandesc_callback(int desc, const char **virname, unsigned long int *scan
|
|||
if(rc == CL_CLEAN && ctx.found_possibly_unwanted)
|
||||
rc = CL_VIRUS;
|
||||
cli_logg_unsetup();
|
||||
perf_done(&ctx);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,9 +28,6 @@
|
|||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#####
|
||||
|
||||
# ClamAV: filter -Werror here
|
||||
CFLAGS=`echo "@CFLAGS@" | sed -e 's/-Werror[^=-]//'`
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
AUTOMAKE_OPTIONS = foreign
|
||||
AM_CPPFLAGS =
|
||||
|
@ -140,6 +137,12 @@ CLEANFILES += libltdl.la \
|
|||
CLEANFILES += $(ltdl_LIBOBJS) $(ltdl_LTLIBOBJS)
|
||||
|
||||
EXTRA_DIST += COPYING.LIB \
|
||||
\
|
||||
\
|
||||
\
|
||||
\
|
||||
\
|
||||
\
|
||||
README
|
||||
|
||||
## --------------------------- ##
|
||||
|
@ -154,7 +157,6 @@ EXTRA_DIST += argz_.h \
|
|||
# doesn't have one that works with the given compiler.
|
||||
all-local $(lib_OBJECTS): $(ARGZ_H)
|
||||
argz.h: argz_.h
|
||||
$(mkinstalldirs) .
|
||||
cp $(srcdir)/argz_.h $@-t
|
||||
mv $@-t $@
|
||||
MOSTLYCLEANFILES += argz.h \
|
||||
|
|
|
@ -201,9 +201,7 @@ BUILD_CONFIGURE_FLAGS = @BUILD_CONFIGURE_FLAGS@
|
|||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFGDIR = @CFGDIR@
|
||||
|
||||
# ClamAV: filter -Werror here
|
||||
CFLAGS = `echo "@CFLAGS@" | sed -e 's/-Werror[^=-]//'`
|
||||
CFLAGS = @CFLAGS@
|
||||
CHECK_CPPFLAGS = @CHECK_CPPFLAGS@
|
||||
CHECK_LIBS = @CHECK_LIBS@
|
||||
CLAMAVGROUP = @CLAMAVGROUP@
|
||||
|
@ -962,7 +960,6 @@ uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES \
|
|||
# doesn't have one that works with the given compiler.
|
||||
all-local $(lib_OBJECTS): $(ARGZ_H)
|
||||
argz.h: argz_.h
|
||||
$(mkinstalldirs) .
|
||||
cp $(srcdir)/argz_.h $@-t
|
||||
mv $@-t $@
|
||||
|
||||
|
|
|
@ -342,6 +342,7 @@ const struct clam_option __clam_options[] = {
|
|||
#ifdef HAVE__INTERNAL__SHA_COLLECT
|
||||
{ "DevCollectHashes", "dev-collect-hashes", 0, TYPE_BOOL, MATCH_BOOL, -1, NULL, FLAG_HIDDEN, OPT_CLAMD | OPT_CLAMSCAN, "", "" },
|
||||
#endif
|
||||
{ "DevPerformance", "dev-performance", 0, TYPE_BOOL, MATCH_BOOL, -1, NULL, FLAG_HIDDEN, OPT_CLAMD | OPT_CLAMSCAN, "", "" },
|
||||
{ "DevLiblog", "dev-liblog", 0, TYPE_BOOL, MATCH_BOOL, -1, NULL, FLAG_HIDDEN, OPT_CLAMD, "", "" },
|
||||
|
||||
/* Freshclam-only entries */
|
||||
|
|
|
@ -385,6 +385,9 @@
|
|||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/times.h> header file. */
|
||||
/* #undef HAVE_SYS_TIMES_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
|
@ -502,7 +505,7 @@
|
|||
/* #undef USE_SYSLOG */
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "clamav-0.97"
|
||||
#define VERSION "devel-clamav-0.97-17-ge0aab5d"
|
||||
|
||||
/* Version suffix for package */
|
||||
#define VERSION_SUFFIX ""
|
||||
|
|
|
@ -467,7 +467,7 @@ int CLAMAPI Scan_CreateInstance(CClamAVScanner **ppScanner) {
|
|||
FAIL(CL_EMEM, "add_instance failed");
|
||||
}
|
||||
unlock_engine();
|
||||
inst->scanopts = CL_SCAN_STDOPT;
|
||||
inst->scanopts = CL_SCAN_STDOPT | CL_SCAN_PERFORMANCE_INFO;
|
||||
*ppScanner = (CClamAVScanner *)inst;
|
||||
logg("Created new instance %p\n", inst);
|
||||
WIN();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue