Browse code

limits in scanbuff

git-svn: trunk@3618

aCaB authored on 2008/02/12 06:31:39
Showing 5 changed files
... ...
@@ -1,3 +1,7 @@
1
+Mon Feb 11 22:16:10 CET 2008 (acab)
2
+-----------------------------------
3
+  * libclamav: account for scanned data in cli_scanbuff too
4
+
1 5
 Mon Feb 11 21:04:30 CET 2008 (acab)
2 6
 -----------------------------------
3 7
   * libclamav: more limit updates, more to come
... ...
@@ -46,21 +46,22 @@
46 46
 #include "cltypes.h"
47 47
 
48 48
 
49
-int cli_scanbuff(const unsigned char *buffer, uint32_t length, const char **virname, const struct cl_engine *engine, cli_file_t ftype)
49
+int cli_scanbuff(const unsigned char *buffer, uint32_t length, cli_ctx *ctx, cli_file_t ftype)
50 50
 {
51 51
 	int ret = CL_CLEAN;
52 52
 	unsigned int i;
53 53
 	struct cli_ac_data mdata;
54 54
 	struct cli_matcher *groot, *troot = NULL;
55
+	const char **virname=ctx->virname;
56
+	const struct cl_engine *engine=ctx->engine;
55 57
 
56 58
     if(!engine) {
57 59
 	cli_errmsg("cli_scanbuff: engine == NULL\n");
58 60
 	return CL_ENULLARG;
59 61
     }
60 62
 
61
-    /* FIXMELIMITS need cts to account limits */
62
-/*     if(cli_updatelimits(ctx, length)!=CL_CLEAN) */
63
-/*         return CL_CLEAN; */
63
+    if(cli_updatelimits(ctx, length)!=CL_CLEAN)
64
+        return CL_CLEAN;
64 65
 
65 66
     groot = engine->root[0]; /* generic signatures */
66 67
 
... ...
@@ -92,7 +92,7 @@ struct cli_target_info {
92 92
     int8_t status; /* 0 == not initialised, 1 == initialised OK, -1 == error */
93 93
 };
94 94
 
95
-int cli_scanbuff(const unsigned char *buffer, uint32_t length, const char **virname, const struct cl_engine *engine, cli_file_t ftype);
95
+int cli_scanbuff(const unsigned char *buffer, uint32_t length, cli_ctx *ctx, cli_file_t ftype);
96 96
 
97 97
 int cli_scandesc(int desc, cli_ctx *ctx, uint8_t otfrec, cli_file_t ftype, uint8_t ftonly, struct cli_matched_type **ftoffset);
98 98
 
... ...
@@ -1050,7 +1050,7 @@ save_text(cli_ctx *ctx, const char *dir, const char *start, size_t len)
1050 1050
 		 *	in this way. It gets the "filetype" wrong and then
1051 1051
 		 *	doesn't scan correctly
1052 1052
 		 */
1053
-		if(cli_scanbuff((char *)p, len, ctx->virname, ctx->engine, CL_TYPE_BINARY_DATA) == CL_VIRUS) {
1053
+		if(cli_scanbuff((char *)p, len, ctx, CL_TYPE_BINARY_DATA) == CL_VIRUS) {
1054 1054
 			cli_dbgmsg("save_text: found %s\n", *ctx->virname);
1055 1055
 			return CL_VIRUS;
1056 1056
 		}
... ...
@@ -749,7 +749,7 @@ static int cli_vba_scandir(const char *dirname, cli_ctx *ctx)
749 749
 		if(ctx->scanned)
750 750
 		    *ctx->scanned += data_len / CL_COUNT_PRECISION;
751 751
 
752
-		if(cli_scanbuff(data, data_len, ctx->virname, ctx->engine, CL_TYPE_MSOLE2) == CL_VIRUS) {
752
+		if(cli_scanbuff(data, data_len, ctx, CL_TYPE_MSOLE2) == CL_VIRUS) {
753 753
 		    free(data);
754 754
 		    ret = CL_VIRUS;
755 755
 		    break;
... ...
@@ -797,7 +797,7 @@ static int cli_vba_scandir(const char *dirname, cli_ctx *ctx)
797 797
 		} else {
798 798
 			if(ctx->scanned)
799 799
 			    *ctx->scanned += vba_project->length[i] / CL_COUNT_PRECISION;
800
-			if(cli_scanbuff(data, vba_project->length[i], ctx->virname, ctx->engine, CL_TYPE_MSOLE2) == CL_VIRUS) {
800
+			if(cli_scanbuff(data, vba_project->length[i], ctx, CL_TYPE_MSOLE2) == CL_VIRUS) {
801 801
 				free(data);
802 802
 				ret = CL_VIRUS;
803 803
 				break;
... ...
@@ -1019,7 +1019,7 @@ static int cli_scanscript(int desc, cli_ctx *ctx)
1019 1019
 				/* we can continue to scan in memory */
1020 1020
 			}
1021 1021
 			/* when we flush the buffer also scan */
1022
-			if(cli_scanbuff(state.out, state.out_pos, ctx->virname, ctx->engine, CL_TYPE_TEXT_ASCII) == CL_VIRUS) {
1022
+			if(cli_scanbuff(state.out, state.out_pos, ctx, CL_TYPE_TEXT_ASCII) == CL_VIRUS) {
1023 1023
 				ret = CL_VIRUS;
1024 1024
 				break;
1025 1025
 			}