Browse code

if there is a version.h.static use that instead of output from svnversion Makefile portability fixes fix assert failure add lcov to top level makefile cleanup after lcov when you run make clean (bb #1112) fix parsing of [^.] character class fix parsing of [r-t] fix handling of @ for URL hashes fix handling of &# inside URLs drop some dead code more unit tests for str portability fixes

git-svn: trunk@4078

Török Edvin authored on 2008/08/04 21:44:16
Showing 31 changed files
... ...
@@ -28,3 +28,6 @@ pkgconfig_DATA = libclamav.pc
28 28
 # don't complain that configuration files and databases are not removed, this is intended
29 29
 distuninstallcheck_listfiles = find . -type f ! -name clamd.conf ! -name freshclam.conf ! -name daily.cvd ! -name main.cvd -print
30 30
 DISTCLEANFILES = target.h
31
+
32
+lcov:
33
+	($(MAKE); cd unit_tests; $(MAKE) lcov)
... ...
@@ -789,6 +789,9 @@ uninstall-am: uninstall-binSCRIPTS uninstall-pkgconfigDATA
789 789
 	tags tags-recursive uninstall uninstall-am \
790 790
 	uninstall-binSCRIPTS uninstall-pkgconfigDATA
791 791
 
792
+
793
+lcov:
794
+	($(MAKE); cd unit_tests; $(MAKE) lcov)
792 795
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
793 796
 # Otherwise a system limit (for SysV at least) may be exceeded.
794 797
 .NOEXPORT:
... ...
@@ -43,3 +43,4 @@ endif
43 43
 LIBS = $(top_builddir)/libclamav/libclamav.la @CLAMAV_MILTER_LIBS@ @THREAD_LIBS@
44 44
 AM_CPPFLAGS = -I$(top_srcdir)/clamd -I$(top_srcdir)/libclamav -I$(top_srcdir)/shared -I$(top_srcdir)
45 45
 EXTRA_DIST = clamav-milter.c INSTALL
46
+CLEANFILES=*.gcda *.gcno
... ...
@@ -251,6 +251,7 @@ top_srcdir = @top_srcdir@
251 251
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@man_MANS = $(top_builddir)/docs/man/clamav-milter.8
252 252
 AM_CPPFLAGS = -I$(top_srcdir)/clamd -I$(top_srcdir)/libclamav -I$(top_srcdir)/shared -I$(top_srcdir)
253 253
 EXTRA_DIST = clamav-milter.c INSTALL
254
+CLEANFILES = *.gcda *.gcno
254 255
 all: all-am
255 256
 
256 257
 .SUFFIXES:
... ...
@@ -584,6 +585,7 @@ install-strip:
584 584
 mostlyclean-generic:
585 585
 
586 586
 clean-generic:
587
+	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
587 588
 
588 589
 distclean-generic:
589 590
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
... ...
@@ -31,3 +31,4 @@ DEFS = @DEFS@ -DCL_NOTHREADS
31 31
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
32 32
 LIBS = $(top_builddir)/libclamav/libclamav.la @THREAD_LIBS@
33 33
 
34
+CLEANFILES=*.gcda *.gcno
... ...
@@ -233,6 +233,7 @@ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
233 233
 
234 234
 # it supports only --help
235 235
 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = clamconf
236
+CLEANFILES = *.gcda *.gcno
236 237
 all: all-am
237 238
 
238 239
 .SUFFIXES:
... ...
@@ -491,6 +492,7 @@ install-strip:
491 491
 mostlyclean-generic:
492 492
 
493 493
 clean-generic:
494
+	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
494 495
 
495 496
 distclean-generic:
496 497
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
... ...
@@ -66,3 +66,4 @@ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
66 66
 # it does support --help and --version but with the default config file
67 67
 # it outputs an error message which tells us to edit the config files
68 68
 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT=clamd$(EXEEXT)
69
+CLEANFILES=*.gcda *.gcno
... ...
@@ -283,6 +283,7 @@ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
283 283
 # it does support --help and --version but with the default config file
284 284
 # it outputs an error message which tells us to edit the config files
285 285
 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = clamd$(EXEEXT)
286
+CLEANFILES = *.gcda *.gcno
286 287
 all: all-am
287 288
 
288 289
 .SUFFIXES:
... ...
@@ -596,6 +597,7 @@ install-strip:
596 596
 mostlyclean-generic:
597 597
 
598 598
 clean-generic:
599
+	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
599 600
 
600 601
 distclean-generic:
601 602
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
... ...
@@ -43,3 +43,4 @@ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/clamscan -I$(top_srcdir)/shared -I
43 43
 LIBS = $(top_builddir)/libclamav/libclamav_internal_utils.la @FRESHCLAM_LIBS@
44 44
 
45 45
 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT=clamdscan$(EXEEXT)
46
+CLEANFILES=*.gcda *.gcno
... ...
@@ -247,6 +247,7 @@ top_srcdir = @top_srcdir@
247 247
 
248 248
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/clamscan -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
249 249
 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = clamdscan$(EXEEXT)
250
+CLEANFILES = *.gcda *.gcno
250 251
 all: all-am
251 252
 
252 253
 .SUFFIXES:
... ...
@@ -536,6 +537,7 @@ install-strip:
536 536
 mostlyclean-generic:
537 537
 
538 538
 clean-generic:
539
+	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
539 540
 
540 541
 distclean-generic:
541 542
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
... ...
@@ -42,4 +42,4 @@ DEFS = @DEFS@ -DCL_NOTHREADS
42 42
 LIBS = $(top_builddir)/libclamav/libclamav.la @THREAD_LIBS@
43 43
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
44 44
 
45
-
45
+CLEANFILES=*.gcda *.gcno
... ...
@@ -242,6 +242,7 @@ clamscan_SOURCES = \
242 242
     manager.h
243 243
 
244 244
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
245
+CLEANFILES = *.gcda *.gcno
245 246
 all: all-am
246 247
 
247 248
 .SUFFIXES:
... ...
@@ -532,6 +533,7 @@ install-strip:
532 532
 mostlyclean-generic:
533 533
 
534 534
 clean-generic:
535
+	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
535 536
 
536 537
 distclean-generic:
537 538
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
... ...
@@ -54,3 +54,4 @@ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
54 54
 LIBS = $(top_builddir)/libclamav/libclamav.la @FRESHCLAM_LIBS@ @THREAD_LIBS@
55 55
 
56 56
 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT=freshclam$(EXEEXT)
57
+CLEANFILES=*.gcda *.gcno
... ...
@@ -257,6 +257,7 @@ freshclam_SOURCES = \
257 257
 
258 258
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
259 259
 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = freshclam$(EXEEXT)
260
+CLEANFILES = *.gcda *.gcno
260 261
 all: all-am
261 262
 
262 263
 .SUFFIXES:
... ...
@@ -596,6 +597,7 @@ install-strip:
596 596
 mostlyclean-generic:
597 597
 
598 598
 clean-generic:
599
+	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
599 600
 
600 601
 distclean-generic:
601 602
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
... ...
@@ -241,7 +241,7 @@ noinst_LTLIBRARIES = libclamav_internal_utils.la
241 241
 EXTRA_DIST = regex/engine.c libclamav.map \
242 242
 	     jsparse/generated/operators.h jsparse/generated/keywords.h jsparse/future_reserved_words.list\
243 243
 	     jsparse/keywords.list jsparse/special_keywords.list jsparse/operators.gperf
244
-
244
+COMMON_CLEANFILES=version.h version.h.tmp *.gcda *.gcno lzma/*.gcda lzma/*.gcno
245 245
 if MAINTAINER_MODE
246 246
 BUILT_SOURCES=jsparse/generated/operators.h jsparse/generated/keywords.h jsparse-keywords.gperf
247 247
 
... ...
@@ -266,7 +266,7 @@ jsparse/generated/keywords.h: jsparse-keywords.gperf
266 266
 	rm keywords-tmp-g
267 267
 	mv keywords-tmp @srcdir@/jsparse/generated/keywords.h
268 268
 
269
-CLEANFILES=jsparse-keywords.gperf @srcdir@/jsparse/generated/operators.h @srcdir@/jsparse/generated/keywords.h
269
+CLEANFILES=$(COMMON_CLEANFILES) @srcdir@/jsparse/generated/operators.h @srcdir@/jsparse/generated/keywords.h
270 270
 else
271
-CLEANFILES=version.h version.h.tmp
271
+CLEANFILES=$(COMMON_CLEANFILES)
272 272
 endif
... ...
@@ -459,10 +459,11 @@ EXTRA_DIST = regex/engine.c libclamav.map \
459 459
 	     jsparse/generated/operators.h jsparse/generated/keywords.h jsparse/future_reserved_words.list\
460 460
 	     jsparse/keywords.list jsparse/special_keywords.list jsparse/operators.gperf
461 461
 
462
+COMMON_CLEANFILES = version.h version.h.tmp *.gcda *.gcno lzma/*.gcda lzma/*.gcno
462 463
 @MAINTAINER_MODE_TRUE@BUILT_SOURCES = jsparse/generated/operators.h jsparse/generated/keywords.h jsparse-keywords.gperf
463 464
 @MAINTAINER_MODE_TRUE@GPERF_FLAGS = -E -t -L ANSI-C -C -F ', TOK_ERROR' -c
464
-@MAINTAINER_MODE_FALSE@CLEANFILES = version.h version.h.tmp
465
-@MAINTAINER_MODE_TRUE@CLEANFILES = jsparse-keywords.gperf @srcdir@/jsparse/generated/operators.h @srcdir@/jsparse/generated/keywords.h
465
+@MAINTAINER_MODE_FALSE@CLEANFILES = $(COMMON_CLEANFILES)
466
+@MAINTAINER_MODE_TRUE@CLEANFILES = $(COMMON_CLEANFILES) @srcdir@/jsparse/generated/operators.h @srcdir@/jsparse/generated/keywords.h
466 467
 all: $(BUILT_SOURCES)
467 468
 	$(MAKE) $(AM_MAKEFLAGS) all-recursive
468 469
 
... ...
@@ -64,7 +64,6 @@
64 64
  * <a href='mailto:somebody@yahoo.com'>to:somebody@yahoo.com</a>*/
65 65
 #define DOMAIN_LISTED		 8
66 66
 #define PHISHY_CLOAKED_NULL	16
67
-#define PHISHY_HEX_URL		32
68 67
 
69 68
 /*
70 69
 * Phishing design documentation,
... ...
@@ -814,9 +813,6 @@ int phishingScan(message* m,const char* dir,cli_ctx* ctx,tag_arguments_t* hrefs)
814 814
 			{
815 815
 				case CL_PHISH_CLEAN:
816 816
 					continue;
817
-				case CL_PHISH_HEX_URL:
818
-					*ctx->virname="Phishing.Heuristics.Email.HexURL";
819
-					break;
820 817
 				case CL_PHISH_NUMERIC_IP:
821 818
 					*ctx->virname="Phishing.Heuristics.Email.Cloaked.NumericIP";
822 819
 					break;
... ...
@@ -969,11 +965,11 @@ static const uint8_t URI_xalpha_nodot[256] = {
969 969
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
970 970
 };
971 971
 
972
-/*!"$%&'()*+,-0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz*/
972
+/*!"#$%&'()*+,-0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz*/
973 973
 static const uint8_t URI_xpalpha_nodot[256] = {
974 974
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
975 975
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
976
-        0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
976
+        0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
977 977
         1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
978 978
         1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
979 979
         1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,
... ...
@@ -1164,19 +1160,6 @@ static enum phish_status phishy_map(int phishy,enum phish_status fallback)
1164 1164
 		return fallback;
1165 1165
 }
1166 1166
 
1167
-static int isEncoded(const char* url)
1168
-{
1169
-	const char* start=url;
1170
-	size_t cnt=0;
1171
-	do{
1172
-		cnt++;
1173
-		start=strstr(start,"&#");
1174
-		if(start)
1175
-			start=strstr(start,";");
1176
-	} while(start);
1177
-	return (cnt-1 >strlen(url)*7/10);/*more than 70% made up of &#;*/
1178
-}
1179
-
1180 1167
 static int whitelist_check(const struct cl_engine* engine,struct url_check* urls,int hostOnly)
1181 1168
 {
1182 1169
 	return whitelist_match(engine,urls->realLink.data,urls->displayLink.data,hostOnly);
... ...
@@ -1220,7 +1203,7 @@ static int hash_match(const struct regex_matcher *rlist, const char *host, size_
1220 1220
 static int url_hash_match(const struct regex_matcher *rlist, const char *inurl, size_t len)
1221 1221
 {
1222 1222
 	char urlbuff[URL_MAX_LEN+3];/* htmlnorm truncates at 1024 bytes + terminating null + slash + host end null */
1223
-	char *url;
1223
+	char *url, *p;
1224 1224
 	const char *urlend = urlbuff + len;
1225 1225
 	char *host_begin;
1226 1226
 	size_t host_len, path_len;
... ...
@@ -1248,6 +1231,10 @@ static int url_hash_match(const struct regex_matcher *rlist, const char *inurl,
1248 1248
 	++host_begin;
1249 1249
 	while((host_begin < urlend) && *host_begin == '/') ++host_begin;
1250 1250
 	while(*host_begin == '.' && host_begin < urlend) ++host_begin;
1251
+	p = strchr(host_begin, '@');
1252
+	if(p)
1253
+		host_begin = p+1;
1254
+
1251 1255
 	host_len = strcspn(host_begin, ":/?");
1252 1256
 	path_begin = host_begin + host_len;
1253 1257
 	if(host_len < len) {
... ...
@@ -1275,21 +1262,24 @@ static int url_hash_match(const struct regex_matcher *rlist, const char *inurl,
1275 1275
 	lp[j] = host_begin;
1276 1276
 
1277 1277
 	pp[0] = path_len;
1278
-	pp[1] = strcspn(path_begin, "?");
1279
-	if(pp[1] != pp[0]) k = 2;
1280
-	else k = 1;
1281
-	pp[k++] = 0;
1282
-	while(k < COMPONENTS+2) {
1283
-		const char *p = strchr(path_begin + pp[k-1] + 1, '/');
1284
-		if(p && p > path_begin) {
1285
-			pp[k++] = p - path_begin;
1286
-		} else
1287
-			break;
1288
-	}
1278
+	if(path_len) {
1279
+		pp[1] = strcspn(path_begin, "?");
1280
+		if(pp[1] != pp[0]) k = 2;
1281
+		else k = 1;
1282
+		pp[k++] = 0;
1283
+		while(k < COMPONENTS+2) {
1284
+			const char *p = strchr(path_begin + pp[k-1] + 1, '/');
1285
+			if(p && p > path_begin) {
1286
+				pp[k++] = p - path_begin;
1287
+			} else
1288
+				break;
1289
+		}
1290
+	} else
1291
+		k = 1;
1289 1292
 
1290 1293
 	for(ji=j;ji < COMPONENTS+1; ji++) {
1291 1294
 		for(ki=0;ki < k; ki++) {
1292
-			assert(pp[ki] < path_len);
1295
+			assert(pp[ki] <= path_len);
1293 1296
 			rc = hash_match(rlist, lp[ji], host_begin + host_len - lp[ji] + 1, path_begin, pp[ki]);
1294 1297
 			if(rc) {
1295 1298
 				return rc;
... ...
@@ -1372,10 +1362,6 @@ static enum phish_status phishingCheck(const struct cl_engine* engine,struct url
1372 1372
 			free_if_needed(&host_url);
1373 1373
 			return CL_PHISH_CLOAKED_NULL;
1374 1374
 		}
1375
-		if(isEncoded(urls->displayLink.data)) {
1376
-			free_if_needed(&host_url);
1377
-			return CL_PHISH_HEX_URL;
1378
-		}
1379 1375
 	}
1380 1376
 
1381 1377
 	if(urls->flags&CHECK_SSL && isSSL(urls->displayLink.data) && !isSSL(urls->realLink.data)) {
... ...
@@ -1430,8 +1416,6 @@ static const char* phishing_ret_toString(enum phish_status rc)
1430 1430
 			return "Visible links is SSL, real link is not";
1431 1431
 		case CL_PHISH_NOMATCH:
1432 1432
 			return "URLs are way too different";
1433
-		case CL_PHISH_HEX_URL:
1434
-			return "Embedded hex urls";
1435 1433
 		case CL_PHISH_HASH0:
1436 1434
 		case CL_PHISH_HASH1:
1437 1435
 		case CL_PHISH_HASH2:
... ...
@@ -65,7 +65,12 @@ struct node {
65 65
 static int build_suffixtree_descend(struct node *n, struct text_buffer *buf, suffix_callback cb, void *cbdata, struct regex_list *regex);
66 66
 /* -----------------*/
67 67
 
68
-static uint8_t dot_bitmap[32];
68
+static uint8_t dot_bitmap[32] = {
69
+	0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
70
+	0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
71
+	0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
72
+	0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
73
+};
69 74
 
70 75
 static struct node* make_node(enum node_type type, struct node *left, struct node *right)
71 76
 {
... ...
@@ -221,8 +226,8 @@ static uint8_t* parse_char_class(const char *pat, size_t *pos)
221 221
 			return dot_bitmap;
222 222
 		} else {
223 223
 			bitmap[pat[*pos]>>3] ^= 1<<(pat[*pos]&0x7);
224
-			++*pos;
225 224
 			range_start = pat[*pos];
225
+			++*pos;
226 226
 			hasprev = 1;
227 227
 		}
228 228
 	} while(pat[*pos]!=']');
... ...
@@ -286,12 +291,15 @@ static struct node* parse_regex(const char *p, size_t *last)
286 286
 				++*last;
287 287
 				break;
288 288
 			case '[':
289
+				++*last;
289 290
 				right = make_charclass( parse_char_class(p, last) );
290 291
 				if(!right)
291 292
 					return NULL;
292 293
 				v = make_node(concat, v, right);
293 294
 				if(!v)
294 295
 					return NULL;
296
+				++*last;
297
+				break;
295 298
 			case '\\':
296 299
 				/* next char is escaped, advance pointer
297 300
 				 * and let fall-through handle it */
... ...
@@ -312,7 +320,7 @@ static struct node* parse_regex(const char *p, size_t *last)
312 312
 
313 313
 static int build_suffixtree_ascend(struct node *n, struct text_buffer *buf, struct node *prev, suffix_callback cb, void *cbdata, struct regex_list *regex)
314 314
 {
315
-	size_t i;
315
+	size_t i, cnt;
316 316
 	while(n) {
317 317
 		struct node *q = n;
318 318
 		switch(n->type) {
... ...
@@ -326,12 +334,17 @@ static int build_suffixtree_ascend(struct node *n, struct text_buffer *buf, stru
326 326
 				n = n->parent;
327 327
 				break;
328 328
 			case leaf_class:
329
-				if(memcmp(n->u.leaf_class_bitmap, dot_bitmap, sizeof(dot_bitmap)) == 0) {
329
+				cnt = 0;
330
+				for(i=0;i<255;i++)
331
+					if (BITMAP_HASSET(n->u.leaf_class_bitmap, i))
332
+						cnt++;
333
+				if (cnt > 16) {
330 334
 					textbuffer_putc(buf, '\0');
331 335
 					if(cb(cbdata, buf->data, buf->pos-1, regex) < 0)
332 336
 						return CL_EMEM;
333 337
 					return 0;
334 338
 				}
339
+				/* handle small classes by expanding */
335 340
 				for(i=0;i<255;i++) {
336 341
 					if(BITMAP_HASSET(n->u.leaf_class_bitmap, i)) {
337 342
 						size_t pos;
... ...
@@ -2,7 +2,6 @@
2 2
 #include "clamav-config.h"
3 3
 #endif
4 4
 #include "version.h"
5
-#include <string.h>
6 5
 
7 6
 #ifndef REPO_VERSION
8 7
 #define REPO_VERSION VERSION
... ...
@@ -35,3 +35,4 @@ lib_LTLIBRARIES = libclamunrar.la
35 35
 endif
36 36
 
37 37
 EXTRA_DIST = libclamunrar.map
38
+CLEANFILES=*.gcda *.gcno
... ...
@@ -246,6 +246,7 @@ top_srcdir = @top_srcdir@
246 246
 
247 247
 @ENABLE_UNRAR_TRUE@lib_LTLIBRARIES = libclamunrar.la
248 248
 EXTRA_DIST = libclamunrar.map
249
+CLEANFILES = *.gcda *.gcno
249 250
 all: all-am
250 251
 
251 252
 .SUFFIXES:
... ...
@@ -448,6 +449,7 @@ install-strip:
448 448
 mostlyclean-generic:
449 449
 
450 450
 clean-generic:
451
+	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
451 452
 
452 453
 distclean-generic:
453 454
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
... ...
@@ -22,3 +22,4 @@ lib_LTLIBRARIES = libclamunrar_iface.la
22 22
 endif
23 23
 
24 24
 EXTRA_DIST = libclamunrar_iface.map
25
+CLEANFILES=*.gcda *.gcno
... ...
@@ -227,6 +227,7 @@ top_srcdir = @top_srcdir@
227 227
 
228 228
 @ENABLE_UNRAR_TRUE@lib_LTLIBRARIES = libclamunrar_iface.la
229 229
 EXTRA_DIST = libclamunrar_iface.map
230
+CLEANFILES = *.gcda *.gcno
230 231
 all: all-am
231 232
 
232 233
 .SUFFIXES:
... ...
@@ -422,6 +423,7 @@ install-strip:
422 422
 mostlyclean-generic:
423 423
 
424 424
 clean-generic:
425
+	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
425 426
 
426 427
 distclean-generic:
427 428
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
... ...
@@ -43,3 +43,4 @@ sigtool_SOURCES = \
43 43
 DEFS = @DEFS@ -DCL_NOTHREADS
44 44
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
45 45
 LIBS = $(top_builddir)/libclamav/libclamav.la @FRESHCLAM_LIBS@ @THREAD_LIBS@
46
+CLEANFILES=*.gcda *.gcno
... ...
@@ -245,6 +245,7 @@ sigtool_SOURCES = \
245 245
     sigtool.c
246 246
 
247 247
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
248
+CLEANFILES = *.gcda *.gcno
248 249
 all: all-am
249 250
 
250 251
 .SUFFIXES:
... ...
@@ -579,6 +580,7 @@ install-strip:
579 579
 mostlyclean-generic:
580 580
 
581 581
 clean-generic:
582
+	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
582 583
 
583 584
 distclean-generic:
584 585
 	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
... ...
@@ -26,7 +26,7 @@ check_clamscan.sh: $(top_builddir)/test/clam.exe
26 26
 $(top_builddir)/test/clam.exe:
27 27
 	(cd $(top_builddir)/test && $(MAKE))
28 28
 
29
-CLEANFILES=lcov.out *.gcno *.gcda *.log /tmp/clamd-test.log $(FILES) test-stderr.log clamscan.log valgrind.log clamdscan.log
29
+CLEANFILES=lcov.out *.gcno *.gcda *.log clamd-test.socket /tmp/clamd-test.log $(FILES) test-stderr.log clamscan.log valgrind.log clamdscan.log
30 30
 EXTRA_DIST=.split input test-clamd.conf test-freshclam.conf valgrind.supp virusaction-test.sh
31 31
 if ENABLE_COVERAGE
32 32
 LCOV_OUTPUT = lcov.out
... ...
@@ -227,7 +227,7 @@ scripts = check_clamd.sh check_freshclam.sh check_sigtool.sh check_clamscan.sh v
227 227
 check_clamav_SOURCES = check_clamav.c check_jsnorm.c check_str.c check_regex.c checks.h $(top_builddir)/libclamav/clamav.h check_disasm.c check_uniq.c
228 228
 check_clamav_CFLAGS = @CHECK_CFLAGS@ -DSRCDIR=\"$(abs_srcdir)\"
229 229
 check_clamav_LDADD = $(top_builddir)/libclamav/libclamav.la @THREAD_LIBS@ @CHECK_LIBS@
230
-CLEANFILES = lcov.out *.gcno *.gcda *.log /tmp/clamd-test.log $(FILES) test-stderr.log clamscan.log valgrind.log clamdscan.log
230
+CLEANFILES = lcov.out *.gcno *.gcda *.log clamd-test.socket /tmp/clamd-test.log $(FILES) test-stderr.log clamscan.log valgrind.log clamdscan.log
231 231
 EXTRA_DIST = .split input test-clamd.conf test-freshclam.conf valgrind.supp virusaction-test.sh
232 232
 @ENABLE_COVERAGE_TRUE@LCOV_OUTPUT = lcov.out
233 233
 @ENABLE_COVERAGE_TRUE@LCOV_HTML = lcov_html
... ...
@@ -1,7 +1,7 @@
1 1
 #!/bin/sh 
2 2
 die() {
3 3
 	test -f /tmp/clamd-test.pid && kill `cat /tmp/clamd-test.pid` 
4
-	rm -rf test-db test-clamd-viraction.conf test-clamd.log test-clamd-heur-pred.conf
4
+	rm -rf test-db test-clamd-viraction.conf test-clamd.log	test-clamd-heur-pred.conf clamd-test.socket
5 5
 	exit $1
6 6
 }
7 7
 run_clamd_test() {
... ...
@@ -41,8 +41,9 @@ cat <$srcdir/test-clamd.conf >test-clamd-viraction.conf
41 41
 echo "VirusEvent `pwd`/$srcdir/virusaction-test.sh `pwd` \"Virus found: %v\"" >>test-clamd-viraction.conf
42 42
 rm -f test-clamd.log
43 43
 run_clamd_test test-clamd-viraction.conf ../test/clam.exe
44
-if ! grep "Virus found: ClamAV-Test-File.UNOFFICIAL" test-clamd.log >/dev/null 2>/dev/null; then
45
-	echo "Virusaction test failed!" >&2;
44
+grep "Virus found: ClamAV-Test-File.UNOFFICIAL" test-clamd.log >/dev/null 2>/dev/null; 
45
+if test ! $? ; then
46
+	echo "Virusaction test failed!" 
46 47
 	cat test-clamd.log
47 48
 	die 5;
48 49
 fi
... ...
@@ -50,14 +51,16 @@ fi
50 50
 # Test HeuristicScanPrecedence feature
51 51
 cat <$srcdir/test-clamd.conf >test-clamd-heur-pred.conf
52 52
 run_clamd_test test-clamd-heur-pred.conf clam-phish-exe
53
-if ! grep "ClamAV-Test-File" clamdscan.log >/dev/null 2>/dev/null; then
53
+grep "ClamAV-Test-File" clamdscan.log >/dev/null 2>/dev/null;
54
+if test ! $?; then
54 55
 	echo "HeuristicScanPrecedence off test failed!" >&2;
55 56
 	cat clamdscan.log;
56 57
 	die 6;
57 58
 fi
58 59
 echo "HeuristicScanPrecedence yes" >>test-clamd-heur-pred.conf
59 60
 run_clamd_test test-clamd-heur-pred.conf clam-phish-exe
60
-if ! grep "Phishing.Heuristics.Email.SpoofedDomain" clamdscan.log >/dev/null 2>/dev/null; then
61
+grep "Phishing.Heuristics.Email.SpoofedDomain" clamdscan.log >/dev/null 2>/dev/null;
62
+if test ! $?; then
61 63
 	echo "HeuristicScanPrecedence on test failed!" >&2;
62 64
 	cat clamdscan.log;
63 65
 	die 6;
... ...
@@ -376,6 +376,12 @@ static const char jstest_buf11[] =
376 376
 static const char jstest_expected11[] =
377 377
 "var n000=123456789;";
378 378
 
379
+static const char jstest_buf12[] =
380
+"var x='test\\u0000test';";
381
+
382
+static const char jstest_expected12[] =
383
+"var n000=\"test\x1test\";";
384
+
379 385
 static struct {
380 386
 	const char *in;
381 387
 	const char *expected;
... ...
@@ -391,7 +397,8 @@ static struct {
391 391
 	{jstest_buf8, jstest_expected8},
392 392
 	{jstest_buf9, jstest_expected9},
393 393
 	{jstest_buf10, jstest_expected10},
394
-	{jstest_buf11, jstest_expected11}
394
+	{jstest_buf11, jstest_expected11},
395
+	{jstest_buf12, jstest_expected12}
395 396
 };
396 397
 
397 398
 START_TEST (tokenizer_basic)
... ...
@@ -166,8 +166,12 @@ static const struct rtest {
166 166
 	const char *realurl;
167 167
 	const char *displayurl;
168 168
 	int result;/* 0 - phish, 1 - whitelisted, 2 - clean, 
169
-		      3 - blacklisted if 2nd db is loaded */
169
+		      3 - blacklisted if 2nd db is loaded,
170
+		      4 - invalid regex*/
170 171
 } rtests[] = {
172
+	{NULL,"http://fake.example.com","&#61;&#61;&#61;&#61;&#61;key.com",0},
173
+	{NULL,"http://key.com","&#61;&#61;&#61;&#61;&#61;key.com",2},
174
+	{NULL,"http://key.com@fake.example.com","key.com",0},
171 175
 	/* entry taken from .wdb with a / appended */
172 176
 	{".+\\.ebayrtm\\.com([/?].*)?:.+\\.ebay\\.(de|com|co\\.uk)([/?].*)?/",
173 177
 		"http://srx.main.ebayrtm.com",
... ...
@@ -188,7 +192,29 @@ static const struct rtest {
188 188
 	{NULL, "http://1.test.example.com/something","test",3},
189 189
 	{NULL, "http://1.test.example.com/2","test",3},
190 190
 	{NULL, "http://user@1.test.example.com/2","test",3},
191
-	{NULL, "http://x.exe","http:///x.exe",2}
191
+	{NULL, "http://user@1.test.example.com/2/test","test",3},
192
+	{NULL, "http://user@1.test.example.com/","test",3},
193
+	{NULL, "http://x.exe","http:///x.exe",2},
194
+	{".+\\.ebayrtm\\.com([/?].*)?:[^.]+\\.ebay\\.(de|com|co\\.uk)/",
195
+		"http://srx.main.ebayrtm.com",
196
+		"pages.ebay.de",
197
+		1 /* should be whitelisted */},
198
+	{".+\\.ebayrtm\\.com([/?].*)?:.+[r-t]\\.ebay\\.(de|com|co\\.uk)/",
199
+		"http://srx.main.ebayrtm.com",
200
+		"pages.ebay.de",
201
+		1 /* should be whitelisted */},
202
+	{".+\\.ebayrtm\\.com([/?].*)?:.+[r-t]\\.ebay\\.(de|com|co\\.uk)/",
203
+		"http://srx.main.ebayrtm.com",
204
+		"pages.ebay.de",
205
+		1 /* should be whitelisted */},
206
+	{"[t-","","",4},
207
+	{NULL,"http://co.uk","http:// co.uk",2},
208
+	{NULL,"http://co.uk","     ",2},
209
+	{NULL,"127.0.0.1","pages.ebay.de",2},
210
+	{".+\\.ebayrtm\\.com([/?].*)?:.+\\.ebay\\.(de|com|co\\.uk)([/?].*)?/",
211
+		"http://pages.ebay.de@fake.example.com","pages.ebay.de",0},
212
+	{NULL,"http://key.com","https://key.com",0},
213
+	{NULL,"http://key.com%00fake.example.com","https://key.com",0},
192 214
 };
193 215
 
194 216
 START_TEST (regex_list_match_test)
... ...
@@ -205,13 +231,18 @@ START_TEST (regex_list_match_test)
205 205
 		return;
206 206
 	}
207 207
 
208
-	fail_unless(rtest->result == 0 || rtest->result == 1,
209
-			"whitelist test result must be either 0 or 1");
208
+	fail_unless(rtest->result == 0 || rtest->result == 1 || rtest->result==4,
209
+			"whitelist test result must be either 0 or 1 or 4");
210 210
 	pattern = cli_strdup(rtest->pattern);
211 211
 	fail_unless(!!pattern, "cli_strdup");
212 212
 
213 213
 	rc = regex_list_add_pattern(&matcher, pattern);
214
-	fail_unless(rc == 0,"regex_list_add_pattern");
214
+	if(rtest->result == 4) {
215
+		fail_unless(rc, "regex_list_add_pattern should return error");
216
+		free(pattern);
217
+		return;
218
+	} else
219
+		fail_unless(rc == 0,"regex_list_add_pattern");
215 220
 	free(pattern);
216 221
 
217 222
 	matcher.list_loaded = 1;
... ...
@@ -110,6 +110,9 @@ START_TEST (test_append_len)
110 110
 {
111 111
 	fail_unless(textbuffer_append_len(&buf, "test",3) != -1, "tbuf append");
112 112
 	fail_unless(buf.data && !strncmp(buf.data,"tes",3), "textbuffer_append_len");
113
+	errmsg_expected();
114
+	fail_unless(textbuffer_append_len(&buf, "test",CLI_MAX_ALLOCATION) == -1, "tbuf append");
115
+	fail_unless(buf.data && !strncmp(buf.data,"tes",3), "textbuffer_append_len");
113 116
 }
114 117
 END_TEST
115 118