git-svn: trunk@4578
Tomasz Kojm authored on 2008/12/30 02:55:30... | ... |
@@ -559,7 +559,8 @@ libclamav_la_SOURCES = \ |
559 | 559 |
version.c\ |
560 | 560 |
version.h\ |
561 | 561 |
mpool.c\ |
562 |
- mpool.h |
|
562 |
+ mpool.h \ |
|
563 |
+ default.h |
|
563 | 564 |
|
564 | 565 |
noinst_LTLIBRARIES = libclamav_internal_utils.la |
565 | 566 |
COMMON_CLEANFILES = version.h version.h.tmp *.gcda *.gcno lzma/*.gcda lzma/*.gcno |
... | ... |
@@ -37,6 +37,7 @@ |
37 | 37 |
#include "matcher-ac.h" |
38 | 38 |
#include "str.h" |
39 | 39 |
#include "textdet.h" |
40 |
+#include "default.h" |
|
40 | 41 |
|
41 | 42 |
#include "htmlnorm.h" |
42 | 43 |
#include "entconv.h" |
... | ... |
@@ -164,7 +165,7 @@ cli_file_t cli_filetype2(int desc, const struct cl_engine *engine) |
164 | 164 |
if(!root) |
165 | 165 |
return ret; |
166 | 166 |
|
167 |
- if(cli_ac_initdata(&mdata, root->ac_partsigs, root->ac_lsigs, AC_DEFAULT_TRACKLEN)) |
|
167 |
+ if(cli_ac_initdata(&mdata, root->ac_partsigs, root->ac_lsigs, CLI_DEFAULT_AC_TRACKLEN)) |
|
168 | 168 |
return ret; |
169 | 169 |
|
170 | 170 |
sret = cli_ac_scanbuff(buff, bread, NULL, NULL, NULL, engine->root[0], &mdata, 0, ret, desc, NULL, AC_SCAN_FT, NULL); |
... | ... |
@@ -174,7 +175,7 @@ cli_file_t cli_filetype2(int desc, const struct cl_engine *engine) |
174 | 174 |
if(sret >= CL_TYPENO) { |
175 | 175 |
ret = sret; |
176 | 176 |
} else { |
177 |
- if(cli_ac_initdata(&mdata, root->ac_partsigs, root->ac_lsigs, AC_DEFAULT_TRACKLEN)) |
|
177 |
+ if(cli_ac_initdata(&mdata, root->ac_partsigs, root->ac_lsigs, CLI_DEFAULT_AC_TRACKLEN)) |
|
178 | 178 |
return ret; |
179 | 179 |
|
180 | 180 |
decoded = (unsigned char *) cli_utf16toascii((char *) buff, bread); |
... | ... |
@@ -209,7 +210,7 @@ cli_file_t cli_filetype2(int desc, const struct cl_engine *engine) |
209 | 209 |
* (just eliminating zeros and matching would introduce false positives */ |
210 | 210 |
if(encoding_normalize_toascii(&in_area, encoding, &out_area) >= 0 && out_area.length > 0) { |
211 | 211 |
out_area.buffer[out_area.length] = '\0'; |
212 |
- if(cli_ac_initdata(&mdata, root->ac_partsigs, root->ac_lsigs, AC_DEFAULT_TRACKLEN)) |
|
212 |
+ if(cli_ac_initdata(&mdata, root->ac_partsigs, root->ac_lsigs, CLI_DEFAULT_AC_TRACKLEN)) |
|
213 | 213 |
return ret; |
214 | 214 |
|
215 | 215 |
if(out_area.length > 0) { |
... | ... |
@@ -40,6 +40,7 @@ |
40 | 40 |
#include "cltypes.h" |
41 | 41 |
#include "str.h" |
42 | 42 |
#include "readdb.h" |
43 |
+#include "default.h" |
|
43 | 44 |
|
44 | 45 |
#include "mpool.h" |
45 | 46 |
|
... | ... |
@@ -933,7 +934,7 @@ int cli_ac_scanbuff(const unsigned char *buffer, uint32_t length, const char **v |
933 | 933 |
return CL_EMEM; |
934 | 934 |
} |
935 | 935 |
|
936 |
- mdata->offmatrix[pt->sigid - 1][0] = cli_malloc(pt->parts * (AC_DEFAULT_TRACKLEN + 1) * sizeof(int32_t)); |
|
936 |
+ mdata->offmatrix[pt->sigid - 1][0] = cli_malloc(pt->parts * (CLI_DEFAULT_AC_TRACKLEN + 1) * sizeof(int32_t)); |
|
937 | 937 |
if(!mdata->offmatrix[pt->sigid - 1][0]) { |
938 | 938 |
cli_errmsg("cli_ac_scanbuff: Can't allocate memory for mdata->offmatrix[%u][0]\n", pt->sigid - 1); |
939 | 939 |
free(mdata->offmatrix[pt->sigid - 1]); |
... | ... |
@@ -942,10 +943,10 @@ int cli_ac_scanbuff(const unsigned char *buffer, uint32_t length, const char **v |
942 | 942 |
free(info.exeinfo.section); |
943 | 943 |
return CL_EMEM; |
944 | 944 |
} |
945 |
- memset(mdata->offmatrix[pt->sigid - 1][0], -1, pt->parts * (AC_DEFAULT_TRACKLEN + 1) * sizeof(int32_t)); |
|
945 |
+ memset(mdata->offmatrix[pt->sigid - 1][0], -1, pt->parts * (CLI_DEFAULT_AC_TRACKLEN + 1) * sizeof(int32_t)); |
|
946 | 946 |
mdata->offmatrix[pt->sigid - 1][0][0] = 0; |
947 | 947 |
for(j = 1; j < pt->parts; j++) { |
948 |
- mdata->offmatrix[pt->sigid - 1][j] = mdata->offmatrix[pt->sigid - 1][0] + j * (AC_DEFAULT_TRACKLEN + 1); |
|
948 |
+ mdata->offmatrix[pt->sigid - 1][j] = mdata->offmatrix[pt->sigid - 1][0] + j * (CLI_DEFAULT_AC_TRACKLEN + 1); |
|
949 | 949 |
mdata->offmatrix[pt->sigid - 1][j][0] = 0; |
950 | 950 |
} |
951 | 951 |
} |
... | ... |
@@ -953,7 +954,7 @@ int cli_ac_scanbuff(const unsigned char *buffer, uint32_t length, const char **v |
953 | 953 |
|
954 | 954 |
if(pt->partno != 1) { |
955 | 955 |
found = 0; |
956 |
- for(j = 1; j <= AC_DEFAULT_TRACKLEN && offmatrix[pt->partno - 2][j] != -1; j++) { |
|
956 |
+ for(j = 1; j <= CLI_DEFAULT_AC_TRACKLEN && offmatrix[pt->partno - 2][j] != -1; j++) { |
|
957 | 957 |
found = 1; |
958 | 958 |
if(pt->maxdist) |
959 | 959 |
if(realoff - offmatrix[pt->partno - 2][j] > pt->maxdist) |
... | ... |
@@ -969,7 +970,7 @@ int cli_ac_scanbuff(const unsigned char *buffer, uint32_t length, const char **v |
969 | 969 |
} |
970 | 970 |
|
971 | 971 |
if(pt->partno == 1 || (found && (pt->partno != pt->parts))) { |
972 |
- offmatrix[pt->partno - 1][0] %= AC_DEFAULT_TRACKLEN; |
|
972 |
+ offmatrix[pt->partno - 1][0] %= CLI_DEFAULT_AC_TRACKLEN; |
|
973 | 973 |
offmatrix[pt->partno - 1][0]++; |
974 | 974 |
offmatrix[pt->partno - 1][offmatrix[pt->partno - 1][0]] = offset + matchend; |
975 | 975 |
|
... | ... |
@@ -990,7 +991,7 @@ int cli_ac_scanbuff(const unsigned char *buffer, uint32_t length, const char **v |
990 | 990 |
type = pt->type; |
991 | 991 |
if(ftoffset && (!*ftoffset || (*ftoffset)->cnt < MAX_EMBEDDED_OBJ || type == CL_TYPE_ZIPSFX) && ((ftype == CL_TYPE_MSEXE && type >= CL_TYPE_SFX) || ((ftype == CL_TYPE_MSEXE || ftype == CL_TYPE_ZIP || ftype == CL_TYPE_MSOLE2) && type == CL_TYPE_MSEXE))) { |
992 | 992 |
/* FIXME: we don't know which offset of the first part is the correct one */ |
993 |
- for(j = 1; j <= AC_DEFAULT_TRACKLEN && offmatrix[0][j] != -1; j++) { |
|
993 |
+ for(j = 1; j <= CLI_DEFAULT_AC_TRACKLEN && offmatrix[0][j] != -1; j++) { |
|
994 | 994 |
if(ac_addtype(ftoffset, type, offmatrix[pt->parts - 1][j], ctx)) { |
995 | 995 |
if(info.exeinfo.section) |
996 | 996 |
free(info.exeinfo.section); |
... | ... |
@@ -999,7 +1000,7 @@ int cli_ac_scanbuff(const unsigned char *buffer, uint32_t length, const char **v |
999 | 999 |
} |
1000 | 1000 |
} |
1001 | 1001 |
|
1002 |
- memset(offmatrix[0], -1, pt->parts * (AC_DEFAULT_TRACKLEN + 1) * sizeof(int32_t)); |
|
1002 |
+ memset(offmatrix[0], -1, pt->parts * (CLI_DEFAULT_AC_TRACKLEN + 1) * sizeof(int32_t)); |
|
1003 | 1003 |
for(j = 0; j < pt->parts; j++) |
1004 | 1004 |
offmatrix[j][0] = 0; |
1005 | 1005 |
} |
... | ... |
@@ -43,6 +43,7 @@ |
43 | 43 |
#include "special.h" |
44 | 44 |
#include "str.h" |
45 | 45 |
#include "cltypes.h" |
46 |
+#include "default.h" |
|
46 | 47 |
|
47 | 48 |
|
48 | 49 |
int cli_scanbuff(const unsigned char *buffer, uint32_t length, cli_ctx *ctx, cli_file_t ftype) |
... | ... |
@@ -72,7 +73,7 @@ int cli_scanbuff(const unsigned char *buffer, uint32_t length, cli_ctx *ctx, cli |
72 | 72 |
|
73 | 73 |
if(troot) { |
74 | 74 |
|
75 |
- if((ret = cli_ac_initdata(&mdata, troot->ac_partsigs, troot->ac_lsigs, AC_DEFAULT_TRACKLEN))) |
|
75 |
+ if((ret = cli_ac_initdata(&mdata, troot->ac_partsigs, troot->ac_lsigs, CLI_DEFAULT_AC_TRACKLEN))) |
|
76 | 76 |
return ret; |
77 | 77 |
|
78 | 78 |
if(troot->ac_only || (ret = cli_bm_scanbuff(buffer, length, virname, troot, 0, ftype, -1)) != CL_VIRUS) |
... | ... |
@@ -84,7 +85,7 @@ int cli_scanbuff(const unsigned char *buffer, uint32_t length, cli_ctx *ctx, cli |
84 | 84 |
return ret; |
85 | 85 |
} |
86 | 86 |
|
87 |
- if((ret = cli_ac_initdata(&mdata, groot->ac_partsigs, groot->ac_lsigs, AC_DEFAULT_TRACKLEN))) |
|
87 |
+ if((ret = cli_ac_initdata(&mdata, groot->ac_partsigs, groot->ac_lsigs, CLI_DEFAULT_AC_TRACKLEN))) |
|
88 | 88 |
return ret; |
89 | 89 |
|
90 | 90 |
if(groot->ac_only || (ret = cli_bm_scanbuff(buffer, length, virname, groot, 0, ftype, -1)) != CL_VIRUS) |
... | ... |
@@ -297,11 +298,11 @@ int cli_scandesc(int desc, cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struc |
297 | 297 |
return CL_EMEM; |
298 | 298 |
} |
299 | 299 |
|
300 |
- if(!ftonly && (ret = cli_ac_initdata(&gdata, groot->ac_partsigs, groot->ac_lsigs, AC_DEFAULT_TRACKLEN))) |
|
300 |
+ if(!ftonly && (ret = cli_ac_initdata(&gdata, groot->ac_partsigs, groot->ac_lsigs, CLI_DEFAULT_AC_TRACKLEN))) |
|
301 | 301 |
return ret; |
302 | 302 |
|
303 | 303 |
if(troot) { |
304 |
- if((ret = cli_ac_initdata(&tdata, troot->ac_partsigs, troot->ac_lsigs, AC_DEFAULT_TRACKLEN))) |
|
304 |
+ if((ret = cli_ac_initdata(&tdata, troot->ac_partsigs, troot->ac_lsigs, CLI_DEFAULT_AC_TRACKLEN))) |
|
305 | 305 |
return ret; |
306 | 306 |
} |
307 | 307 |
|
... | ... |
@@ -76,6 +76,7 @@ static pthread_mutex_t cli_gentemp_mutex = PTHREAD_MUTEX_INITIALIZER; |
76 | 76 |
#include "regex/regex.h" |
77 | 77 |
#include "ltdl.h" |
78 | 78 |
#include "matcher-ac.h" |
79 |
+#include "default.h" |
|
79 | 80 |
|
80 | 81 |
#ifndef O_BINARY |
81 | 82 |
#define O_BINARY 0 |
... | ... |
@@ -214,17 +215,17 @@ struct cl_engine *cl_engine_new(void) |
214 | 214 |
} |
215 | 215 |
|
216 | 216 |
/* Setup default limits */ |
217 |
- new->maxscansize = 104857600; |
|
218 |
- new->maxfilesize = 26214400; |
|
219 |
- new->maxreclevel = 16; |
|
220 |
- new->maxfiles = 10000; |
|
221 |
- new->min_cc_count = 3; |
|
222 |
- new->min_ssn_count = 3; |
|
217 |
+ new->maxscansize = CLI_DEFAULT_MAXSCANSIZE; |
|
218 |
+ new->maxfilesize = CLI_DEFAULT_MAXFILESIZE; |
|
219 |
+ new->maxreclevel = CLI_DEFAULT_MAXRECLEVEL; |
|
220 |
+ new->maxfiles = CLI_DEFAULT_MAXFILES; |
|
221 |
+ new->min_cc_count = CLI_DEFAULT_MIN_CC_COUNT; |
|
222 |
+ new->min_ssn_count = CLI_DEFAULT_MIN_SSN_COUNT; |
|
223 | 223 |
|
224 | 224 |
new->refcount = 1; |
225 | 225 |
new->ac_only = 0; |
226 |
- new->ac_mindepth = AC_DEFAULT_MIN_DEPTH; |
|
227 |
- new->ac_maxdepth = AC_DEFAULT_MAX_DEPTH; |
|
226 |
+ new->ac_mindepth = CLI_DEFAULT_AC_MINDEPTH; |
|
227 |
+ new->ac_maxdepth = CLI_DEFAULT_AC_MAXDEPTH; |
|
228 | 228 |
|
229 | 229 |
#ifdef USE_MPOOL |
230 | 230 |
if(!(new->mempool = mp_create())) { |
... | ... |
@@ -53,6 +53,7 @@ |
53 | 53 |
#include "readdb.h" |
54 | 54 |
#include "jsparse/textbuf.h" |
55 | 55 |
#include "regex_suffix.h" |
56 |
+#include "default.h" |
|
56 | 57 |
|
57 | 58 |
#include "mpool.h" |
58 | 59 |
|
... | ... |
@@ -287,7 +288,7 @@ int regex_list_match(struct regex_matcher* matcher,char* real_url,const char* di |
287 | 287 |
buffer[buffer_len]=0; |
288 | 288 |
cli_dbgmsg("Looking up in regex_list: %s\n", buffer); |
289 | 289 |
|
290 |
- if((rc = cli_ac_initdata(&mdata, 0, 0, AC_DEFAULT_TRACKLEN))) |
|
290 |
+ if((rc = cli_ac_initdata(&mdata, 0, 0, CLI_DEFAULT_AC_TRACKLEN))) |
|
291 | 291 |
return rc; |
292 | 292 |
|
293 | 293 |
bufrev = cli_strdup(buffer); |
... | ... |
@@ -30,6 +30,7 @@ |
30 | 30 |
#include "../libclamav/matcher.h" |
31 | 31 |
#include "../libclamav/matcher-ac.h" |
32 | 32 |
#include "../libclamav/matcher-bm.h" |
33 |
+#include "../libclamav/default.h" |
|
33 | 34 |
#include "checks.h" |
34 | 35 |
|
35 | 36 |
static const struct ac_testdata_s { |
... | ... |
@@ -64,7 +65,7 @@ START_TEST (test_ac_scanbuff) { |
64 | 64 |
#ifdef USE_MPOOL |
65 | 65 |
root->mempool = mp_create(); |
66 | 66 |
#endif |
67 |
- ret = cli_ac_init(root, AC_DEFAULT_MIN_DEPTH, AC_DEFAULT_MAX_DEPTH); |
|
67 |
+ ret = cli_ac_init(root, CLI_DEFAULT_AC_MINDEPTH, CLI_DEFAULT_AC_MAXDEPTH); |
|
68 | 68 |
fail_unless(ret == CL_SUCCESS, "cli_ac_init() failed"); |
69 | 69 |
|
70 | 70 |
for(i = 0; ac_testdata[i].data; i++) { |
... | ... |
@@ -75,7 +76,7 @@ START_TEST (test_ac_scanbuff) { |
75 | 75 |
ret = cli_ac_buildtrie(root); |
76 | 76 |
fail_unless(ret == CL_SUCCESS, "cli_ac_buildtrie() failed"); |
77 | 77 |
|
78 |
- ret = cli_ac_initdata(&mdata, root->ac_partsigs, 0, AC_DEFAULT_TRACKLEN); |
|
78 |
+ ret = cli_ac_initdata(&mdata, root->ac_partsigs, 0, CLI_DEFAULT_AC_TRACKLEN); |
|
79 | 79 |
fail_unless(ret == CL_SUCCESS, "cli_ac_initdata() failed"); |
80 | 80 |
|
81 | 81 |
for(i = 0; ac_testdata[i].data; i++) { |