diff --git a/ChangeLog b/ChangeLog index 3cae48955..056b43c76 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Feb 13 14:12:30 CET 2009 (tk) +--------------------------------- + * libclamav/matcher.c: cli_scanbuff: add support for external acdata + Fri Feb 13 14:21:54 EET 2009 (edwin) ------------------------------------ * unit_tests/preload_run.sh, unit_tests/valgrind_tests.sh: increase diff --git a/libclamav/blob.c b/libclamav/blob.c index 4fcf36f66..d6455a17b 100644 --- a/libclamav/blob.c +++ b/libclamav/blob.c @@ -590,7 +590,7 @@ fileblobAddData(fileblob *fb, const unsigned char *data, size_t len) *ctx->scanned += (unsigned long)len / CL_COUNT_PRECISION; fb->bytes_scanned += (unsigned long)len; - if((len > 5) && cli_updatelimits(ctx, len)==CL_CLEAN && (cli_scanbuff(data, (unsigned int)len, ctx->virname, ctx->engine, CL_TYPE_BINARY_DATA) == CL_VIRUS)) { + if((len > 5) && cli_updatelimits(ctx, len)==CL_CLEAN && (cli_scanbuff(data, (unsigned int)len, ctx->virname, ctx->engine, CL_TYPE_BINARY_DATA, NULL) == CL_VIRUS)) { cli_dbgmsg("fileblobAddData: found %s\n", *ctx->virname); fb->isInfected = 1; } diff --git a/libclamav/matcher.c b/libclamav/matcher.c index c637aabfa..b531c2f51 100644 --- a/libclamav/matcher.c +++ b/libclamav/matcher.c @@ -46,7 +46,7 @@ #include "default.h" -int cli_scanbuff(const unsigned char *buffer, uint32_t length, cli_ctx *ctx, cli_file_t ftype) +int cli_scanbuff(const unsigned char *buffer, uint32_t length, cli_ctx *ctx, cli_file_t ftype, struct cli_ac_data **acdata) { int ret = CL_CLEAN; unsigned int i; @@ -73,25 +73,27 @@ int cli_scanbuff(const unsigned char *buffer, uint32_t length, cli_ctx *ctx, cli if(troot) { - if((ret = cli_ac_initdata(&mdata, troot->ac_partsigs, troot->ac_lsigs, CLI_DEFAULT_AC_TRACKLEN))) + if(!acdata && (ret = cli_ac_initdata(&mdata, troot->ac_partsigs, troot->ac_lsigs, CLI_DEFAULT_AC_TRACKLEN))) return ret; if(troot->ac_only || (ret = cli_bm_scanbuff(buffer, length, virname, troot, 0, ftype, -1)) != CL_VIRUS) - ret = cli_ac_scanbuff(buffer, length, virname, NULL, NULL, troot, &mdata, 0, ftype, -1, NULL, AC_SCAN_VIR, NULL); + ret = cli_ac_scanbuff(buffer, length, virname, NULL, NULL, troot, acdata ? (acdata[0]) : (&mdata), 0, ftype, -1, NULL, AC_SCAN_VIR, NULL); - cli_ac_freedata(&mdata); + if(!acdata) + cli_ac_freedata(&mdata); if(ret == CL_VIRUS) return ret; } - if((ret = cli_ac_initdata(&mdata, groot->ac_partsigs, groot->ac_lsigs, CLI_DEFAULT_AC_TRACKLEN))) + if(!acdata && (ret = cli_ac_initdata(&mdata, groot->ac_partsigs, groot->ac_lsigs, CLI_DEFAULT_AC_TRACKLEN))) return ret; if(groot->ac_only || (ret = cli_bm_scanbuff(buffer, length, virname, groot, 0, ftype, -1)) != CL_VIRUS) - ret = cli_ac_scanbuff(buffer, length, virname, NULL, NULL, groot, &mdata, 0, ftype, -1, NULL, AC_SCAN_VIR, NULL); + ret = cli_ac_scanbuff(buffer, length, virname, NULL, NULL, groot, acdata ? (acdata[1]) : (&mdata), 0, ftype, -1, NULL, AC_SCAN_VIR, NULL); - cli_ac_freedata(&mdata); + if(!acdata) + cli_ac_freedata(&mdata); return ret; } diff --git a/libclamav/matcher.h b/libclamav/matcher.h index 1ef52300e..f0d85e8b5 100644 --- a/libclamav/matcher.h +++ b/libclamav/matcher.h @@ -123,7 +123,7 @@ struct cli_target_info { int8_t status; /* 0 == not initialised, 1 == initialised OK, -1 == error */ }; -int cli_scanbuff(const unsigned char *buffer, uint32_t length, cli_ctx *ctx, cli_file_t ftype); +int cli_scanbuff(const unsigned char *buffer, uint32_t length, 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); diff --git a/libclamav/mbox.c b/libclamav/mbox.c index 887795957..ff7b54b5c 100644 --- a/libclamav/mbox.c +++ b/libclamav/mbox.c @@ -1043,7 +1043,7 @@ save_text(cli_ctx *ctx, const char *dir, const char *start, size_t len) * in this way. It gets the "filetype" wrong and then * doesn't scan correctly */ - if(cli_scanbuff((char *)p, len, ctx, CL_TYPE_BINARY_DATA) == CL_VIRUS) { + if(cli_scanbuff((char *)p, len, ctx, CL_TYPE_BINARY_DATA, NULL) == CL_VIRUS) { cli_dbgmsg("save_text: found %s\n", *ctx->virname); return CL_VIRUS; } diff --git a/libclamav/scanners.c b/libclamav/scanners.c index 887935287..63f8fceb9 100644 --- a/libclamav/scanners.c +++ b/libclamav/scanners.c @@ -773,7 +773,7 @@ static int cli_vba_scandir(const char *dirname, cli_ctx *ctx, struct uniq *U) /* cli_dbgmsg("Project content:\n%s", data); */ if(ctx->scanned) *ctx->scanned += data_len / CL_COUNT_PRECISION; - if(cli_scanbuff(data, data_len, ctx, CL_TYPE_MSOLE2) == CL_VIRUS) { + if(cli_scanbuff(data, data_len, ctx, CL_TYPE_MSOLE2, NULL) == CL_VIRUS) { free(data); ret = CL_VIRUS; break; @@ -831,7 +831,7 @@ static int cli_vba_scandir(const char *dirname, cli_ctx *ctx, struct uniq *U) cli_dbgmsg("Project content:\n%s", data); if(ctx->scanned) *ctx->scanned += vba_project->length[i] / CL_COUNT_PRECISION; - if(cli_scanbuff(data, vba_project->length[i], ctx, CL_TYPE_MSOLE2) == CL_VIRUS) { + if(cli_scanbuff(data, vba_project->length[i], ctx, CL_TYPE_MSOLE2, NULL) == CL_VIRUS) { free(data); ret = CL_VIRUS; break; @@ -1048,7 +1048,7 @@ static int cli_scanscript(int desc, cli_ctx *ctx) /* we can continue to scan in memory */ } /* when we flush the buffer also scan */ - if(cli_scanbuff(state.out, state.out_pos, ctx, CL_TYPE_TEXT_ASCII) == CL_VIRUS) { + if(cli_scanbuff(state.out, state.out_pos, ctx, CL_TYPE_TEXT_ASCII, NULL) == CL_VIRUS) { ret = CL_VIRUS; break; }