Browse code

enable full db load, fix ram usage

aCaB authored on 2011/01/10 00:47:40
Showing 3 changed files
... ...
@@ -67,7 +67,7 @@ int hm_addhash(struct cli_matcher *root, const char *hash, uint32_t size, const
67 67
     hashlen /= 2;
68 68
     ht = &root->hm.sizehashes[type];
69 69
     if(!root->hm.htinint[type]) {
70
-	i = cli_htu32_init(ht, 5000, root->mempool);
70
+	i = cli_htu32_init(ht, 64, root->mempool);
71 71
 	if(i) return i;
72 72
 	root->hm.htinint[type] = 1;
73 73
     }
... ...
@@ -94,9 +94,9 @@ int hm_addhash(struct cli_matcher *root, const char *hash, uint32_t size, const
94 94
 
95 95
     if(szh->items == szh->max) {
96 96
 	if(!szh->max)
97
-	    szh->max = 1024;
97
+	    szh->max = 1;
98 98
 	else
99
-	    szh->max = szh->max + szh->max / 2;
99
+	    szh->max += 1 + szh->max / 2;
100 100
 
101 101
 	szh->hash_array = mpool_realloc2(root->mempool, szh->hash_array, hashlen * szh->max);
102 102
 	if(!szh->hash_array) {
... ...
@@ -197,6 +197,7 @@ void hm_flush(struct cli_matcher *root) {
197 197
 		if(p) szh->hash_array = p;
198 198
 		p = mpool_realloc(root->mempool, szh->virusnames, sizeof(*szh->virusnames) * szh->items);
199 199
 		if(p) szh->virusnames = p;
200
+		szh->max = szh->items;
200 201
 	    }
201 202
 	    if(szh->items > 1)
202 203
 		hm_sort(szh, 0, szh->items, keylen);
... ...
@@ -2134,7 +2134,6 @@ static int cli_loadhash(FILE *fs, struct cl_engine *engine, unsigned int *signo,
2134 2134
 	return ret;
2135 2135
     }
2136 2136
 
2137
-    hm_flush(db);
2138 2137
     if(signo)
2139 2138
 	*signo += sigs;
2140 2139
 
... ...
@@ -3230,6 +3229,15 @@ int cl_engine_compile(struct cl_engine *engine)
3230 3230
     if(engine->md5_mdb)
3231 3231
 	cli_dbgmsg("MD5 sigs (PE sections): %u\n", engine->md5_mdb->md5_patterns);
3232 3232
 
3233
+    if(engine->hm_hdb)
3234
+	hm_flush(engine->hm_hdb);
3235
+
3236
+    if(engine->hm_mdb)
3237
+	hm_flush(engine->hm_mdb);
3238
+
3239
+    if(engine->hm_fp)
3240
+	hm_flush(engine->hm_fp);
3241
+
3233 3242
     if((ret = cli_build_regex_list(engine->whitelist_matcher))) {
3234 3243
 	    return ret;
3235 3244
     }
... ...
@@ -37,6 +37,11 @@
37 37
 	cli_strbcasestr(ext, ".fp")    ||	\
38 38
 	cli_strbcasestr(ext, ".mdb")   ||	\
39 39
 	cli_strbcasestr(ext, ".mdu")   ||	\
40
+	cli_strbcasestr(ext, ".hsb")   ||	\
41
+	cli_strbcasestr(ext, ".hsu")   ||	\
42
+	cli_strbcasestr(ext, ".sfp")   ||	\
43
+	cli_strbcasestr(ext, ".msb")   ||	\
44
+	cli_strbcasestr(ext, ".msu")   ||	\
40 45
 	cli_strbcasestr(ext, ".ndb")   ||	\
41 46
 	cli_strbcasestr(ext, ".ndu")   ||	\
42 47
 	cli_strbcasestr(ext, ".ldb")   ||	\