don't let scandesc rehash when we already have an hash

0.96
aCaB 15 years ago
parent c7f2ca7d9c
commit 548b55beb8
  1. 2
      libclamav/matcher.h
  2. 8
      libclamav/scanners.c

@ -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);

@ -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--;

Loading…
Cancel
Save