- make regex* and hash* behave properly (either include or exclude from the pool entirely)
- cleanup the ifdefs and make a single macro
- fixup the proto for dconf (re-enables make check in mpool-mode)
- check the possibility to entirely wipe frees from error paths in mpool-mode
  (this totally simplifies the code)



git-svn-id: file:///var/lib/svn/clamav-devel/branches/mpool@4271 77e5149b-7576-45b1-b177-96237e5ba77b
0.95
aCaB 17 years ago
parent b0c3171680
commit a5746c2512
  1. 3
      libclamav/clamav.h
  2. 2
      libclamav/dconf.c
  3. 2
      libclamav/hashtab.c
  4. 1
      libclamav/hashtab.h
  5. 11
      libclamav/matcher-ac.c
  6. 1
      libclamav/matcher.h
  7. 10
      libclamav/readdb.c
  8. 6
      libclamav/regex_list.c

@ -153,9 +153,8 @@ struct cl_engine {
/* PUA categories (to be included or excluded) */
char *pua_cats;
#ifdef USE_MPOOL
/* Used for memory pools */
void *mempool;
#endif
};
struct cl_limits {

@ -112,7 +112,7 @@ static struct dconf_module modules[] = {
{ NULL, NULL, 0, 0 }
};
#ifdef USE_MPOOL
#ifdef USE_MPOOL /* MPOOLFIXME : worthless? */
struct cli_dconf *cli_dconf_init(mpool_t *mempool)
#else
struct cli_dconf *cli_dconf_init(void)

@ -176,9 +176,7 @@ int hashtab_init(struct hashtable *s,size_t capacity)
PROFILE_INIT(s);
capacity = nearest_power(capacity);
s->htable = cli_calloc(capacity,sizeof(*s->htable));
if(!s->htable)
return CL_EMEM;
s->capacity = capacity;

@ -25,7 +25,6 @@
#include <stdio.h>
#include <stddef.h>
#include "cltypes.h"
typedef long element_data;
/* define this for debugging/profiling purposes only, NOT in production/release code */

@ -1444,11 +1444,11 @@ int cli_ac_addsig(struct cli_matcher *root, const char *virname, const char *hex
#ifdef USE_MPOOL
{
unsigned int mpoolhexlen = (strlen(hex ? hex : hexsig) / 2 + 1) * sizeof(uint16_t);
unsigned int mpoolpattsz = (strlen(hex ? hex : hexsig) / 2 + 1) * sizeof(uint16_t);
uint16_t *mpoolpatt = cli_hex2ui(hex ? hex : hexsig);
if(mpoolpatt) {
if((new->pattern = mpool_alloc(root->mempool, mpoolhexlen, NULL)) != NULL)
memcpy(new->pattern, mpoolpatt, mpoolhexlen);
if((new->pattern = mpool_alloc(root->mempool, mpoolpattsz, NULL)) != NULL)
memcpy(new->pattern, mpoolpatt, mpoolpattsz);
free(mpoolpatt);
} else new->pattern = NULL;
}
@ -1541,9 +1541,8 @@ int cli_ac_addsig(struct cli_matcher *root, const char *virname, const char *hex
{
char *mpoolvirname = cli_virname((char *) virname, options & CL_DB_OFFICIAL, 0);
if(mpoolvirname) {
unsigned int mpoolvirnamesz = strlen(mpoolvirname) + 1;
if((new->virname = mpool_alloc(root->mempool, mpoolvirnamesz, NULL)) != NULL)
memcpy(new->virname, mpoolvirname, mpoolvirnamesz);
if((new->virname = mpool_alloc(root->mempool, strlen(mpoolvirname) + 1, NULL)) != NULL)
strcpy(new->virname, mpoolvirname);
free(mpoolvirname);
} else new->virname = NULL;
}

@ -38,7 +38,6 @@
#include "mpool.h"
#endif
#define CLI_MATCH_WILDCARD 0xff00
#define CLI_MATCH_CHAR 0x0000
#define CLI_MATCH_IGNORE 0x0100

@ -1249,8 +1249,9 @@ static int cli_loadftm(FILE *fs, struct cl_engine **engine, unsigned int options
{
unsigned char *mpoolmagic = cli_hex2str(tokens[2]);
if(mpoolmagic) {
if((new->magic = mpool_alloc((*engine)->mempool, strlen(mpoolmagic) + 1, NULL)))
strcpy(new->magic, mpoolmagic);
unsigned int mpoolmagicsz = strlen(tokens[2]) / 2 + 1;
if((new->magic = mpool_alloc((*engine)->mempool, mpoolmagicsz, NULL)))
memcpy(new->magic, mpoolmagic, mpoolmagicsz);
free(mpoolmagic);
} else new->magic = NULL;
}
@ -1272,8 +1273,9 @@ static int cli_loadftm(FILE *fs, struct cl_engine **engine, unsigned int options
{
unsigned char *mpooltname = cli_hex2str(tokens[3]);
if(mpooltname) {
if((new->tname = mpool_alloc((*engine)->mempool, strlen(mpooltname) + 1, NULL)))
strcpy(new->tname, mpooltname);
unsigned int mpooltnamesz = strlen(tokens[3]) / 2 + 1;
if((new->tname = mpool_alloc((*engine)->mempool, mpooltnamesz, NULL)))
memcpy(new->tname, mpooltname, mpooltnamesz);
free(mpooltname);
} else new->tname = NULL;
}

@ -355,13 +355,7 @@ int init_regex_list(struct regex_matcher* matcher)
matcher->list_inited=1;
matcher->list_built=0;
matcher->list_loaded=0;
#ifdef USE_MPOOL
hashtab_init(&matcher->suffix_hash, 10);
matcher->suffixes.mempool = matcher->mempool;
matcher->md5_hashes.mempool = matcher->mempool;
#else
hashtab_init(&matcher->suffix_hash, 10);
#endif
if((rc = cli_ac_init(&matcher->suffixes, 2, 32))) {
return rc;
}

Loading…
Cancel
Save