enable full db load, fix ram usage

remotes/push_mirror/multihash
aCaB 15 years ago
parent 125827cf0b
commit 0fcc8112ff
  1. 7
      libclamav/matcher-hash.c
  2. 10
      libclamav/readdb.c
  3. 5
      libclamav/readdb.h

@ -67,7 +67,7 @@ int hm_addhash(struct cli_matcher *root, const char *hash, uint32_t size, const
hashlen /= 2;
ht = &root->hm.sizehashes[type];
if(!root->hm.htinint[type]) {
i = cli_htu32_init(ht, 5000, root->mempool);
i = cli_htu32_init(ht, 64, root->mempool);
if(i) return i;
root->hm.htinint[type] = 1;
}
@ -94,9 +94,9 @@ int hm_addhash(struct cli_matcher *root, const char *hash, uint32_t size, const
if(szh->items == szh->max) {
if(!szh->max)
szh->max = 1024;
szh->max = 1;
else
szh->max = szh->max + szh->max / 2;
szh->max += 1 + szh->max / 2;
szh->hash_array = mpool_realloc2(root->mempool, szh->hash_array, hashlen * szh->max);
if(!szh->hash_array) {
@ -197,6 +197,7 @@ void hm_flush(struct cli_matcher *root) {
if(p) szh->hash_array = p;
p = mpool_realloc(root->mempool, szh->virusnames, sizeof(*szh->virusnames) * szh->items);
if(p) szh->virusnames = p;
szh->max = szh->items;
}
if(szh->items > 1)
hm_sort(szh, 0, szh->items, keylen);

@ -2134,7 +2134,6 @@ static int cli_loadhash(FILE *fs, struct cl_engine *engine, unsigned int *signo,
return ret;
}
hm_flush(db);
if(signo)
*signo += sigs;
@ -3230,6 +3229,15 @@ int cl_engine_compile(struct cl_engine *engine)
if(engine->md5_mdb)
cli_dbgmsg("MD5 sigs (PE sections): %u\n", engine->md5_mdb->md5_patterns);
if(engine->hm_hdb)
hm_flush(engine->hm_hdb);
if(engine->hm_mdb)
hm_flush(engine->hm_mdb);
if(engine->hm_fp)
hm_flush(engine->hm_fp);
if((ret = cli_build_regex_list(engine->whitelist_matcher))) {
return ret;
}

@ -37,6 +37,11 @@
cli_strbcasestr(ext, ".fp") || \
cli_strbcasestr(ext, ".mdb") || \
cli_strbcasestr(ext, ".mdu") || \
cli_strbcasestr(ext, ".hsb") || \
cli_strbcasestr(ext, ".hsu") || \
cli_strbcasestr(ext, ".sfp") || \
cli_strbcasestr(ext, ".msb") || \
cli_strbcasestr(ext, ".msu") || \
cli_strbcasestr(ext, ".ndb") || \
cli_strbcasestr(ext, ".ndu") || \
cli_strbcasestr(ext, ".ldb") || \

Loading…
Cancel
Save