From 548b55beb87b3887ffce300f1b937f6247569ac0 Mon Sep 17 00:00:00 2001 From: aCaB Date: Thu, 4 Mar 2010 19:52:33 +0100 Subject: [PATCH] don't let scandesc rehash when we already have an hash --- libclamav/matcher.h | 2 +- libclamav/scanners.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libclamav/matcher.h b/libclamav/matcher.h index d7ae8a3fc..2d5d020bd 100644 --- a/libclamav/matcher.h +++ b/libclamav/matcher.h @@ -164,7 +164,7 @@ struct cli_target_info { int cli_scanbuff(const unsigned char *buffer, uint32_t length, uint32_t offset, cli_ctx *ctx, cli_file_t ftype, struct cli_ac_data **acdata); int cli_scandesc(int desc, cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli_matched_type **ftoffset, unsigned int acmode); -int cli_fmap_scandesc(cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli_matched_type **ftoffset, unsigned int acmode, unsigned char *digest); +int cli_fmap_scandesc(cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli_matched_type **ftoffset, unsigned int acmode, unsigned char *refhash); int cli_caloff(const char *offstr, struct cli_target_info *info, fmap_t *map, unsigned int target, uint32_t *offdata, uint32_t *offset_min, uint32_t *offset_max); int cli_checkfp(unsigned char *digest, size_t size, cli_ctx *ctx); diff --git a/libclamav/scanners.c b/libclamav/scanners.c index e6c5448d8..9864aa4d4 100644 --- a/libclamav/scanners.c +++ b/libclamav/scanners.c @@ -1685,7 +1685,7 @@ static int cli_scanembpe(int desc, cli_ctx *ctx) return CL_CLEAN; } -static int cli_scanraw(cli_ctx *ctx, cli_file_t type, uint8_t typercg, cli_file_t *dettype) +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; struct cli_matched_type *ftoffset = NULL, *fpt; @@ -1703,7 +1703,7 @@ static int cli_scanraw(cli_ctx *ctx, cli_file_t type, uint8_t typercg, cli_file_ if(typercg) acmode |= AC_SCAN_FT; - ret = cli_fmap_scandesc(ctx, type == CL_TYPE_TEXT_ASCII ? 0 : type, 0, &ftoffset, acmode, NULL); + ret = cli_fmap_scandesc(ctx, type == CL_TYPE_TEXT_ASCII ? 0 : type, 0, &ftoffset, acmode, refhash); if(ret >= CL_TYPENO) { ctx->recursion++; @@ -1953,7 +1953,7 @@ int cli_magic_scandesc(int desc, cli_ctx *ctx) return CL_EMEM; if(type != CL_TYPE_IGNORED && ctx->engine->sdb) { - if((ret = cli_scanraw(ctx, type, 0, &dettype)) == CL_VIRUS) { + if((ret = cli_scanraw(ctx, type, 0, &dettype, hash)) == CL_VIRUS) { ret = cli_checkfp(hash, hashed_size, ctx); funmap(*ctx->fmap); ctx->fmap--; @@ -2220,7 +2220,7 @@ int cli_magic_scandesc(int desc, cli_ctx *ctx) /* CL_TYPE_HTML: raw HTML files are not scanned, unless safety measure activated via DCONF */ if(type != CL_TYPE_IGNORED && (type != CL_TYPE_HTML || !(DCONF_DOC & DOC_CONF_HTML_SKIPRAW)) && !ctx->engine->sdb) { - if(cli_scanraw(ctx, type, typercg, &dettype) == CL_VIRUS) { + if(cli_scanraw(ctx, type, typercg, &dettype, hash) == CL_VIRUS) { ret = cli_checkfp(hash, hashed_size, ctx); funmap(*ctx->fmap); ctx->fmap--;