git-svn: trunk@4781
Tomasz Kojm authored on 2009/02/13 21:42:35... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Fri Feb 13 14:12:30 CET 2009 (tk) |
|
2 |
+--------------------------------- |
|
3 |
+ * libclamav/matcher.c: cli_scanbuff: add support for external acdata |
|
4 |
+ |
|
1 | 5 |
Fri Feb 13 14:21:54 EET 2009 (edwin) |
2 | 6 |
------------------------------------ |
3 | 7 |
* unit_tests/preload_run.sh, unit_tests/valgrind_tests.sh: increase |
... | ... |
@@ -590,7 +590,7 @@ fileblobAddData(fileblob *fb, const unsigned char *data, size_t len) |
590 | 590 |
*ctx->scanned += (unsigned long)len / CL_COUNT_PRECISION; |
591 | 591 |
fb->bytes_scanned += (unsigned long)len; |
592 | 592 |
|
593 |
- 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)) { |
|
593 |
+ 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)) { |
|
594 | 594 |
cli_dbgmsg("fileblobAddData: found %s\n", *ctx->virname); |
595 | 595 |
fb->isInfected = 1; |
596 | 596 |
} |
... | ... |
@@ -46,7 +46,7 @@ |
46 | 46 |
#include "default.h" |
47 | 47 |
|
48 | 48 |
|
49 |
-int cli_scanbuff(const unsigned char *buffer, uint32_t length, cli_ctx *ctx, cli_file_t ftype) |
|
49 |
+int cli_scanbuff(const unsigned char *buffer, uint32_t length, cli_ctx *ctx, cli_file_t ftype, struct cli_ac_data **acdata) |
|
50 | 50 |
{ |
51 | 51 |
int ret = CL_CLEAN; |
52 | 52 |
unsigned int i; |
... | ... |
@@ -73,25 +73,27 @@ int cli_scanbuff(const unsigned char *buffer, uint32_t length, cli_ctx *ctx, cli |
73 | 73 |
|
74 | 74 |
if(troot) { |
75 | 75 |
|
76 |
- if((ret = cli_ac_initdata(&mdata, troot->ac_partsigs, troot->ac_lsigs, CLI_DEFAULT_AC_TRACKLEN))) |
|
76 |
+ if(!acdata && (ret = cli_ac_initdata(&mdata, troot->ac_partsigs, troot->ac_lsigs, CLI_DEFAULT_AC_TRACKLEN))) |
|
77 | 77 |
return ret; |
78 | 78 |
|
79 | 79 |
if(troot->ac_only || (ret = cli_bm_scanbuff(buffer, length, virname, troot, 0, ftype, -1)) != CL_VIRUS) |
80 |
- ret = cli_ac_scanbuff(buffer, length, virname, NULL, NULL, troot, &mdata, 0, ftype, -1, NULL, AC_SCAN_VIR, NULL); |
|
80 |
+ ret = cli_ac_scanbuff(buffer, length, virname, NULL, NULL, troot, acdata ? (acdata[0]) : (&mdata), 0, ftype, -1, NULL, AC_SCAN_VIR, NULL); |
|
81 | 81 |
|
82 |
- cli_ac_freedata(&mdata); |
|
82 |
+ if(!acdata) |
|
83 |
+ cli_ac_freedata(&mdata); |
|
83 | 84 |
|
84 | 85 |
if(ret == CL_VIRUS) |
85 | 86 |
return ret; |
86 | 87 |
} |
87 | 88 |
|
88 |
- if((ret = cli_ac_initdata(&mdata, groot->ac_partsigs, groot->ac_lsigs, CLI_DEFAULT_AC_TRACKLEN))) |
|
89 |
+ if(!acdata && (ret = cli_ac_initdata(&mdata, groot->ac_partsigs, groot->ac_lsigs, CLI_DEFAULT_AC_TRACKLEN))) |
|
89 | 90 |
return ret; |
90 | 91 |
|
91 | 92 |
if(groot->ac_only || (ret = cli_bm_scanbuff(buffer, length, virname, groot, 0, ftype, -1)) != CL_VIRUS) |
92 |
- ret = cli_ac_scanbuff(buffer, length, virname, NULL, NULL, groot, &mdata, 0, ftype, -1, NULL, AC_SCAN_VIR, NULL); |
|
93 |
+ ret = cli_ac_scanbuff(buffer, length, virname, NULL, NULL, groot, acdata ? (acdata[1]) : (&mdata), 0, ftype, -1, NULL, AC_SCAN_VIR, NULL); |
|
93 | 94 |
|
94 |
- cli_ac_freedata(&mdata); |
|
95 |
+ if(!acdata) |
|
96 |
+ cli_ac_freedata(&mdata); |
|
95 | 97 |
|
96 | 98 |
return ret; |
97 | 99 |
} |
... | ... |
@@ -123,7 +123,7 @@ struct cli_target_info { |
123 | 123 |
int8_t status; /* 0 == not initialised, 1 == initialised OK, -1 == error */ |
124 | 124 |
}; |
125 | 125 |
|
126 |
-int cli_scanbuff(const unsigned char *buffer, uint32_t length, cli_ctx *ctx, cli_file_t ftype); |
|
126 |
+int cli_scanbuff(const unsigned char *buffer, uint32_t length, cli_ctx *ctx, cli_file_t ftype, struct cli_ac_data **acdata); |
|
127 | 127 |
|
128 | 128 |
int cli_scandesc(int desc, cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli_matched_type **ftoffset, unsigned int acmode); |
129 | 129 |
|
... | ... |
@@ -1043,7 +1043,7 @@ save_text(cli_ctx *ctx, const char *dir, const char *start, size_t len) |
1043 | 1043 |
* in this way. It gets the "filetype" wrong and then |
1044 | 1044 |
* doesn't scan correctly |
1045 | 1045 |
*/ |
1046 |
- if(cli_scanbuff((char *)p, len, ctx, CL_TYPE_BINARY_DATA) == CL_VIRUS) { |
|
1046 |
+ if(cli_scanbuff((char *)p, len, ctx, CL_TYPE_BINARY_DATA, NULL) == CL_VIRUS) { |
|
1047 | 1047 |
cli_dbgmsg("save_text: found %s\n", *ctx->virname); |
1048 | 1048 |
return CL_VIRUS; |
1049 | 1049 |
} |
... | ... |
@@ -773,7 +773,7 @@ static int cli_vba_scandir(const char *dirname, cli_ctx *ctx, struct uniq *U) |
773 | 773 |
/* cli_dbgmsg("Project content:\n%s", data); */ |
774 | 774 |
if(ctx->scanned) |
775 | 775 |
*ctx->scanned += data_len / CL_COUNT_PRECISION; |
776 |
- if(cli_scanbuff(data, data_len, ctx, CL_TYPE_MSOLE2) == CL_VIRUS) { |
|
776 |
+ if(cli_scanbuff(data, data_len, ctx, CL_TYPE_MSOLE2, NULL) == CL_VIRUS) { |
|
777 | 777 |
free(data); |
778 | 778 |
ret = CL_VIRUS; |
779 | 779 |
break; |
... | ... |
@@ -831,7 +831,7 @@ static int cli_vba_scandir(const char *dirname, cli_ctx *ctx, struct uniq *U) |
831 | 831 |
cli_dbgmsg("Project content:\n%s", data); |
832 | 832 |
if(ctx->scanned) |
833 | 833 |
*ctx->scanned += vba_project->length[i] / CL_COUNT_PRECISION; |
834 |
- if(cli_scanbuff(data, vba_project->length[i], ctx, CL_TYPE_MSOLE2) == CL_VIRUS) { |
|
834 |
+ if(cli_scanbuff(data, vba_project->length[i], ctx, CL_TYPE_MSOLE2, NULL) == CL_VIRUS) { |
|
835 | 835 |
free(data); |
836 | 836 |
ret = CL_VIRUS; |
837 | 837 |
break; |
... | ... |
@@ -1048,7 +1048,7 @@ static int cli_scanscript(int desc, cli_ctx *ctx) |
1048 | 1048 |
/* we can continue to scan in memory */ |
1049 | 1049 |
} |
1050 | 1050 |
/* when we flush the buffer also scan */ |
1051 |
- if(cli_scanbuff(state.out, state.out_pos, ctx, CL_TYPE_TEXT_ASCII) == CL_VIRUS) { |
|
1051 |
+ if(cli_scanbuff(state.out, state.out_pos, ctx, CL_TYPE_TEXT_ASCII, NULL) == CL_VIRUS) { |
|
1052 | 1052 |
ret = CL_VIRUS; |
1053 | 1053 |
break; |
1054 | 1054 |
} |