|
|
|
@ -98,7 +98,6 @@ static inline int matcher_run(const struct cli_matcher *root, |
|
|
|
|
struct cli_ac_result **acres, |
|
|
|
|
fmap_t *map, |
|
|
|
|
struct cli_bm_off *offdata, |
|
|
|
|
uint32_t *viroffset, |
|
|
|
|
cli_ctx *ctx) |
|
|
|
|
{ |
|
|
|
|
int ret; |
|
|
|
@ -139,17 +138,20 @@ static inline int matcher_run(const struct cli_matcher *root, |
|
|
|
|
/* Don't use prefiltering for BM offset mode, since BM keeps tracks
|
|
|
|
|
* of offsets itself, and doesn't work if we skip chunks of input |
|
|
|
|
* data */ |
|
|
|
|
ret = cli_bm_scanbuff(orig_buffer, orig_length, virname, NULL, root, orig_offset, tinfo, offdata, viroffset); |
|
|
|
|
ret = cli_bm_scanbuff(orig_buffer, orig_length, virname, NULL, root, orig_offset, tinfo, offdata, ctx); |
|
|
|
|
} else { |
|
|
|
|
ret = cli_bm_scanbuff(buffer, length, virname, NULL, root, offset, tinfo, offdata, viroffset); |
|
|
|
|
ret = cli_bm_scanbuff(buffer, length, virname, NULL, root, offset, tinfo, offdata, ctx); |
|
|
|
|
} |
|
|
|
|
if (ret == CL_VIRUS) { |
|
|
|
|
if (ctx) { |
|
|
|
|
if (ret != CL_CLEAN) { |
|
|
|
|
if (ret != CL_VIRUS) |
|
|
|
|
return ret; |
|
|
|
|
|
|
|
|
|
/* else (ret == CL_VIRUS) */ |
|
|
|
|
if (SCAN_ALL) |
|
|
|
|
viruses_found = 1; |
|
|
|
|
else { |
|
|
|
|
cli_append_virus(ctx, *virname); |
|
|
|
|
if (SCAN_ALL) |
|
|
|
|
viruses_found++; |
|
|
|
|
else |
|
|
|
|
return ret; |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -197,7 +199,7 @@ int cli_scanbuff(const unsigned char *buffer, uint32_t length, uint32_t offset, |
|
|
|
|
if(!acdata && (ret = cli_ac_initdata(&mdata, troot->ac_partsigs, troot->ac_lsigs, troot->ac_reloff_num, CLI_DEFAULT_AC_TRACKLEN))) |
|
|
|
|
return ret; |
|
|
|
|
|
|
|
|
|
ret = matcher_run(troot, buffer, length, &virname, acdata ? (acdata[0]): (&mdata), offset, NULL, ftype, NULL, AC_SCAN_VIR, NULL, *ctx->fmap, NULL, NULL, ctx); |
|
|
|
|
ret = matcher_run(troot, buffer, length, &virname, acdata ? (acdata[0]): (&mdata), offset, NULL, ftype, NULL, AC_SCAN_VIR, NULL, *ctx->fmap, NULL, ctx); |
|
|
|
|
|
|
|
|
|
if(!acdata) |
|
|
|
|
cli_ac_freedata(&mdata); |
|
|
|
@ -217,7 +219,7 @@ int cli_scanbuff(const unsigned char *buffer, uint32_t length, uint32_t offset, |
|
|
|
|
if(!acdata && (ret = cli_ac_initdata(&mdata, groot->ac_partsigs, groot->ac_lsigs, groot->ac_reloff_num, CLI_DEFAULT_AC_TRACKLEN))) |
|
|
|
|
return ret; |
|
|
|
|
|
|
|
|
|
ret = matcher_run(groot, buffer, length, &virname, acdata ? (acdata[1]): (&mdata), offset, NULL, ftype, NULL, AC_SCAN_VIR, NULL, *ctx->fmap, NULL, NULL, ctx); |
|
|
|
|
ret = matcher_run(groot, buffer, length, &virname, acdata ? (acdata[1]): (&mdata), offset, NULL, ftype, NULL, AC_SCAN_VIR, NULL, *ctx->fmap, NULL, ctx); |
|
|
|
|
|
|
|
|
|
if(!acdata) |
|
|
|
|
cli_ac_freedata(&mdata); |
|
|
|
@ -731,7 +733,6 @@ int cli_fmap_scandesc(cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli |
|
|
|
|
fmap_t *map = *ctx->fmap; |
|
|
|
|
struct cli_matcher *hdb, *fp; |
|
|
|
|
const char *virname = NULL; |
|
|
|
|
uint32_t viroffset = 0; |
|
|
|
|
uint32_t viruses_found = 0; |
|
|
|
|
void *md5ctx, *sha1ctx, *sha256ctx; |
|
|
|
|
|
|
|
|
@ -877,8 +878,7 @@ int cli_fmap_scandesc(cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli |
|
|
|
|
|
|
|
|
|
if(troot) { |
|
|
|
|
virname = NULL; |
|
|
|
|
viroffset = 0; |
|
|
|
|
ret = matcher_run(troot, buff, bytes, &virname, &tdata, offset, &info, ftype, ftoffset, acmode, acres, map, bm_offmode ? &toff : NULL, &viroffset, ctx); |
|
|
|
|
ret = matcher_run(troot, buff, bytes, &virname, &tdata, offset, &info, ftype, ftoffset, acmode, acres, map, bm_offmode ? &toff : NULL, ctx); |
|
|
|
|
|
|
|
|
|
if (virname) { |
|
|
|
|
/* virname already appended by matcher_run */ |
|
|
|
@ -905,8 +905,7 @@ int cli_fmap_scandesc(cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli |
|
|
|
|
|
|
|
|
|
if(!ftonly) { |
|
|
|
|
virname = NULL; |
|
|
|
|
viroffset = 0; |
|
|
|
|
ret = matcher_run(groot, buff, bytes, &virname, &gdata, offset, &info, ftype, ftoffset, acmode, acres, map, NULL, &viroffset, ctx); |
|
|
|
|
ret = matcher_run(groot, buff, bytes, &virname, &gdata, offset, &info, ftype, ftoffset, acmode, acres, map, NULL, ctx); |
|
|
|
|
|
|
|
|
|
if (virname) { |
|
|
|
|
/* virname already appended by matcher_run */ |
|
|
|
@ -948,11 +947,6 @@ int cli_fmap_scandesc(cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(SCAN_ALL && viroffset) { |
|
|
|
|
offset = viroffset; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(bytes < SCANBUFF) |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|