[Pkg-clamav-commits] [SCM] Debian repository for ClamAV branch, debian/unstable, updated. debian/0.95+dfsg-1-6156-g094ec9b

Tomasz Kojm tkojm at clamav.net
Sun Apr 4 01:04:59 UTC 2010


The following commit has been merged in the debian/unstable branch:
commit 0c190b52f78322ca6cd808bf06b346ca66bbb750
Author: Tomasz Kojm <tkojm at clamav.net>
Date:   Fri Sep 18 20:02:42 2009 +0200

    libclamav/matcher-bm.c: use mpool in BM's offset mode

diff --git a/ChangeLog b/ChangeLog
index 294262f..9b4a534 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Fri Sep 18 20:02:06 CEST 2009 (tk)
+----------------------------------
+ * libclamav/matcher-bm.c: use mpool in BM's offset mode
+
 Thu Sep 17 22:36:30 CEST 2009 (tk)
 ----------------------------------
  * libclamav/matcher-ac.c: implement word delimiter (B) as requested in bb#1631
diff --git a/libclamav/matcher-bm.c b/libclamav/matcher-bm.c
index 7c8eda6..1ba1021 100644
--- a/libclamav/matcher-bm.c
+++ b/libclamav/matcher-bm.c
@@ -167,15 +167,15 @@ int cli_bm_initoff(const struct cli_matcher *root, struct cli_bm_off *data, int
     info.fsize = sb.st_size;
 
     data->cnt = data->pos = 0;
-    data->offtab = (uint32_t *) cli_malloc(root->bm_patterns * sizeof(uint32_t));
+    data->offtab = (uint32_t *) mpool_malloc(root->mempool, root->bm_patterns * sizeof(uint32_t));
     if(!data->offtab) {
 	cli_errmsg("cli_bm_initoff: Can't allocate memory for data->offtab\n");
 	return CL_EMEM;
     }
-    data->offset = (uint32_t *) cli_malloc(root->bm_patterns * sizeof(uint32_t));
+    data->offset = (uint32_t *) mpool_malloc(root->mempool, root->bm_patterns * sizeof(uint32_t));
     if(!data->offset) {
 	cli_errmsg("cli_bm_initoff: Can't allocate memory for data->offset\n");
-	free(data->offtab);
+	mpool_free(root->mempool, data->offtab);
 	return CL_EMEM;
     }
     for(i = 0; i < root->bm_patterns; i++) {
@@ -187,8 +187,8 @@ int cli_bm_initoff(const struct cli_matcher *root, struct cli_bm_off *data, int
 	    cli_errmsg("cli_bm_initoff: Can't calculate relative offset in signature for %s\n", patt->virname);
 	    if(info.exeinfo.section)
 		free(info.exeinfo.section);
-	    free(data->offtab);
-	    free(data->offset);
+	    mpool_free(root->mempool, data->offtab);
+	    mpool_free(root->mempool, data->offset);
 	    return ret;
 	} else if((data->offset[patt->offset_min] != CLI_OFF_NONE) && (data->offset[patt->offset_min] + patt->length <= info.fsize)) {
 	    if(!data->cnt || (data->offset[patt->offset_min] != data->offtab[data->cnt - 1])) {
@@ -204,11 +204,11 @@ int cli_bm_initoff(const struct cli_matcher *root, struct cli_bm_off *data, int
     return CL_SUCCESS;
 }
 
-void cli_bm_freeoff(struct cli_bm_off *data)
+void cli_bm_freeoff(struct cli_bm_off *data, const struct cli_matcher *root)
 {
-    free(data->offset);
+    mpool_free(root->mempool, data->offset);
     data->offset = NULL;
-    free(data->offtab);
+    mpool_free(root->mempool, data->offtab);
     data->offtab = NULL;
 }
 
diff --git a/libclamav/matcher-bm.h b/libclamav/matcher-bm.h
index 75e2e94..5cca947 100644
--- a/libclamav/matcher-bm.h
+++ b/libclamav/matcher-bm.h
@@ -42,7 +42,7 @@ struct cli_bm_off {
 int cli_bm_addpatt(struct cli_matcher *root, struct cli_bm_patt *pattern, const char *offset);
 int cli_bm_init(struct cli_matcher *root);
 int cli_bm_initoff(const struct cli_matcher *root, struct cli_bm_off *data, int fd);
-void cli_bm_freeoff(struct cli_bm_off *data);
+void cli_bm_freeoff(struct cli_bm_off *data, const struct cli_matcher *root);
 int cli_bm_scanbuff(const unsigned char *buffer, uint32_t length, const char **virname, const struct cli_matcher *root, uint32_t offset, int fd, struct cli_bm_off *offdata);
 void cli_bm_free(struct cli_matcher *root);
 
diff --git a/libclamav/matcher.c b/libclamav/matcher.c
index 9573f8f..525c856 100644
--- a/libclamav/matcher.c
+++ b/libclamav/matcher.c
@@ -423,7 +423,7 @@ int cli_scandesc(int desc, cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struc
 		    cli_ac_freedata(&gdata);
 		cli_ac_freedata(&tdata);
 		if(bm_offmode)
-		    cli_bm_freeoff(&toff);
+		    cli_bm_freeoff(&toff, troot);
 
 		if(cli_checkfp(desc, ctx))
 		    return CL_CLEAN;
@@ -442,7 +442,7 @@ int cli_scandesc(int desc, cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struc
 		if(troot) {
 		    cli_ac_freedata(&tdata);
 		    if(bm_offmode)
-			cli_bm_freeoff(&toff);
+			cli_bm_freeoff(&toff, troot);
 		}
 		if(cli_checkfp(desc, ctx))
 		    return CL_CLEAN;
@@ -489,7 +489,7 @@ int cli_scandesc(int desc, cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struc
 	}
 	cli_ac_freedata(&tdata);
 	if(bm_offmode)
-	    cli_bm_freeoff(&toff);
+	    cli_bm_freeoff(&toff, troot);
     }
 
     if(groot) {

-- 
Debian repository for ClamAV



More information about the Pkg-clamav-commits mailing list