Browse code

don't let scandesc rehash when we already have an hash

aCaB authored on 2010/03/05 03:52:33
Showing 2 changed files
... ...
@@ -164,7 +164,7 @@ struct cli_target_info {
164 164
 int cli_scanbuff(const unsigned char *buffer, uint32_t length, uint32_t offset, cli_ctx *ctx, cli_file_t ftype, struct cli_ac_data **acdata);
165 165
 
166 166
 int cli_scandesc(int desc, cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli_matched_type **ftoffset, unsigned int acmode);
167
-int cli_fmap_scandesc(cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli_matched_type **ftoffset, unsigned int acmode, unsigned char *digest);
167
+int cli_fmap_scandesc(cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli_matched_type **ftoffset, unsigned int acmode, unsigned char *refhash);
168 168
 int cli_caloff(const char *offstr, struct cli_target_info *info, fmap_t *map, unsigned int target, uint32_t *offdata, uint32_t *offset_min, uint32_t *offset_max);
169 169
 
170 170
 int cli_checkfp(unsigned char *digest, size_t size, cli_ctx *ctx);
... ...
@@ -1685,7 +1685,7 @@ static int cli_scanembpe(int desc, cli_ctx *ctx)
1685 1685
     return CL_CLEAN;
1686 1686
 }
1687 1687
 
1688
-static int cli_scanraw(cli_ctx *ctx, cli_file_t type, uint8_t typercg, cli_file_t *dettype)
1688
+static int cli_scanraw(cli_ctx *ctx, cli_file_t type, uint8_t typercg, cli_file_t *dettype, unsigned char *refhash)
1689 1689
 {
1690 1690
 	int ret = CL_CLEAN, nret = CL_CLEAN;
1691 1691
 	struct cli_matched_type *ftoffset = NULL, *fpt;
... ...
@@ -1703,7 +1703,7 @@ static int cli_scanraw(cli_ctx *ctx, cli_file_t type, uint8_t typercg, cli_file_
1703 1703
     if(typercg)
1704 1704
 	acmode |= AC_SCAN_FT;
1705 1705
 
1706
-    ret = cli_fmap_scandesc(ctx, type == CL_TYPE_TEXT_ASCII ? 0 : type, 0, &ftoffset, acmode, NULL);
1706
+    ret = cli_fmap_scandesc(ctx, type == CL_TYPE_TEXT_ASCII ? 0 : type, 0, &ftoffset, acmode, refhash);
1707 1707
 
1708 1708
     if(ret >= CL_TYPENO) {
1709 1709
 	ctx->recursion++;
... ...
@@ -1953,7 +1953,7 @@ int cli_magic_scandesc(int desc, cli_ctx *ctx)
1953 1953
 	return CL_EMEM;
1954 1954
 
1955 1955
     if(type != CL_TYPE_IGNORED && ctx->engine->sdb) {
1956
-	if((ret = cli_scanraw(ctx, type, 0, &dettype)) == CL_VIRUS) {
1956
+	if((ret = cli_scanraw(ctx, type, 0, &dettype, hash)) == CL_VIRUS) {
1957 1957
 	    ret = cli_checkfp(hash, hashed_size, ctx);
1958 1958
 	    funmap(*ctx->fmap);
1959 1959
 	    ctx->fmap--;
... ...
@@ -2220,7 +2220,7 @@ int cli_magic_scandesc(int desc, cli_ctx *ctx)
2220 2220
 
2221 2221
     /* CL_TYPE_HTML: raw HTML files are not scanned, unless safety measure activated via DCONF */
2222 2222
     if(type != CL_TYPE_IGNORED && (type != CL_TYPE_HTML || !(DCONF_DOC & DOC_CONF_HTML_SKIPRAW)) && !ctx->engine->sdb) {
2223
-	if(cli_scanraw(ctx, type, typercg, &dettype) == CL_VIRUS) {
2223
+	if(cli_scanraw(ctx, type, typercg, &dettype, hash) == CL_VIRUS) {
2224 2224
 	    ret =  cli_checkfp(hash, hashed_size, ctx);
2225 2225
 	    funmap(*ctx->fmap);
2226 2226
 	    ctx->fmap--;