Browse code

fix type 7 signature matching (bb #1368).

git-svn: trunk@4788

Török Edvin authored on 2009/02/15 00:35:26
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Sat Feb 14 18:04:55 EET 2009 (edwin)
2
+------------------------------------
3
+ * libclamav/scanners.c: fix type 7 signature matching (bb #1368).
4
+
1 5
 Sat Feb 14 11:43:10 EET 2009 (edwin)
2 6
 ------------------------------------
3 7
  * clamd/others.c, clamd/others.h, clamd/server-th.c: Initialize
... ...
@@ -91,6 +91,7 @@
91 91
 #include <zlib.h>
92 92
 #include "unzip.h"
93 93
 #include "dlp.h"
94
+#include "default.h"
94 95
 
95 96
 #ifdef HAVE_BZLIB_H
96 97
 #include <bzlib.h>
... ...
@@ -1004,8 +1005,11 @@ static int cli_scanscript(int desc, cli_ctx *ctx)
1004 1004
 	char *tmpname = NULL;
1005 1005
 	int ofd = -1, ret;
1006 1006
 	ssize_t nread;
1007
-	const struct cli_matcher *root = ctx->engine->root[7];
1008
-	uint32_t maxpatlen = root ? root->maxpatlen : 0;
1007
+	const struct cli_matcher *troot = ctx->engine->root[7];
1008
+	uint32_t maxpatlen = troot ? troot->maxpatlen : 0;
1009
+	struct cli_matcher *groot = ctx->engine->root[0];
1010
+	struct cli_ac_data gmdata, tmdata;
1011
+	struct cli_ac_data *mdata[2];
1009 1012
 
1010 1013
 	cli_dbgmsg("in cli_scanscript()\n");
1011 1014
 
... ...
@@ -1037,6 +1041,16 @@ static int cli_scanscript(int desc, cli_ctx *ctx)
1037 1037
 	text_normalize_init(&state, normalized, SCANBUFF + maxpatlen);
1038 1038
 	ret = CL_CLEAN;
1039 1039
 
1040
+	if ((ret = cli_ac_initdata(&tmdata, troot->ac_partsigs, troot->ac_lsigs, CLI_DEFAULT_AC_TRACKLEN)))
1041
+	    return ret;
1042
+
1043
+	if ((ret = cli_ac_initdata(&gmdata, groot->ac_partsigs, groot->ac_lsigs, CLI_DEFAULT_AC_TRACKLEN))) {
1044
+	    cli_ac_freedata(&tmdata);
1045
+	    return ret;
1046
+	}
1047
+	mdata[0] = &tmdata;
1048
+	mdata[1] = &gmdata;
1049
+
1040 1050
 	do {
1041 1051
 		nread = cli_readn(desc, buff, sizeof(buff));
1042 1052
 		if(nread <= 0 || state.out_pos + nread > state.out_len) {
... ...
@@ -1048,7 +1062,7 @@ static int cli_scanscript(int desc, cli_ctx *ctx)
1048 1048
 				/* we can continue to scan in memory */
1049 1049
 			}
1050 1050
 			/* when we flush the buffer also scan */
1051
-			if(cli_scanbuff(state.out, state.out_pos, ctx, CL_TYPE_TEXT_ASCII, NULL) == CL_VIRUS) {
1051
+			if(cli_scanbuff(state.out, state.out_pos, ctx, CL_TYPE_TEXT_ASCII, mdata) == CL_VIRUS) {
1052 1052
 				ret = CL_VIRUS;
1053 1053
 				break;
1054 1054
 			}
... ...
@@ -1065,6 +1079,8 @@ static int cli_scanscript(int desc, cli_ctx *ctx)
1065 1065
 		 * and using while(){} loop would mean code duplication */
1066 1066
 	} while (nread > 0);
1067 1067
 
1068
+	cli_ac_freedata(&tmdata);
1069
+	cli_ac_freedata(&gmdata);
1068 1070
 	if(ctx->engine->keeptmp) {
1069 1071
 		free(tmpname);
1070 1072
 		close(ofd);