Browse code

addhash fixes

aCaB authored on 2011/01/08 06:26:16
Showing 1 changed files
... ...
@@ -62,6 +62,7 @@ int hm_addhash(struct cli_matcher *root, const char *hash, uint32_t size, const
62 62
 	return CL_EARG;
63 63
     }
64 64
 
65
+    hashlen /= 2;
65 66
     ht = &root->hm.sizehashes[type];
66 67
     if(!root->hm.htinint[type]) {
67 68
 	i = cli_htu32_init(ht, 5000, root->mempool);
... ...
@@ -101,14 +102,14 @@ int hm_addhash(struct cli_matcher *root, const char *hash, uint32_t size, const
101 101
 	    return CL_EMEM;
102 102
 	}
103 103
 
104
-	szh->virusnames = mpool_realloc2(root->mempool, szh->hash_array, sizeof(*szh->virusnames) * szh->max);
104
+	szh->virusnames = mpool_realloc2(root->mempool, szh->virusnames, sizeof(*szh->virusnames) * szh->max);
105 105
 	if(!szh->virusnames) {
106 106
 	    cli_errmsg("ht_add: failed to grow virusname array to %u entries\n", szh->max);
107 107
 	    return CL_EMEM;
108 108
 	}
109 109
     }
110 110
 
111
-    memcpy(&szh->hash_array[szh->items * hashlen], binhash, hashlen / 2);
111
+    memcpy(&szh->hash_array[szh->items * hashlen], binhash, hashlen);
112 112
     szh->virusnames[szh->items] = virusname;
113 113
     szh->items++;
114 114
     
... ...
@@ -174,7 +175,6 @@ void hm_flush(struct cli_matcher *root) {
174 174
     if(!root)
175 175
 	return;
176 176
 
177
-
178 177
     for(type = CLI_HASH_MD5; type < CLI_HASH_AVAIL_TYPES; type++) {
179 178
 	struct cli_htu32 *ht = &root->hm.sizehashes[type];
180 179
 	const struct cli_htu32_element *item = NULL;