Browse code

Create fewer bounce message FPs

git-svn: trunk@1960

Nigel Horne authored on 2006/05/05 20:24:07
Showing 3 changed files
... ...
@@ -1,3 +1,7 @@
1
+Fri May  5 12:23:23 BST 2006 (njh)
2
+----------------------------------
3
+  * clamav-milter:	Create fewer bounce message FPs
4
+
1 5
 Wed May  3 10:35:40 BST 2006 (njh)
2 6
 ----------------------------------
3 7
   * libclamav/scanners.c:	Pass full CTX into the mbox code
... ...
@@ -309,7 +309,7 @@ author an e-mail.
309 309
 
310 310
 5. BUG REPORTS
311 311
 
312
-Please send bug reports and/or comments to Nigel Horne <njh@despammed.com> or
312
+Please send bug reports and/or comments to Nigel Horne <njh@clamav.net> or
313 313
 bugs@clamav.net.
314 314
 
315 315
 Various tips will go here, for example
... ...
@@ -23,9 +23,9 @@
23 23
  *
24 24
  * For installation instructions see the file INSTALL that came with this file
25 25
  */
26
-static	char	const	rcsid[] = "$Id: clamav-milter.c,v 1.236 2006/04/23 13:00:49 nigelhorne Exp $";
26
+static	char	const	rcsid[] = "$Id: clamav-milter.c,v 1.237 2006/05/05 11:22:42 nigelhorne Exp $";
27 27
 
28
-#define	CM_VERSION	"devel-230406"
28
+#define	CM_VERSION	"devel-050506"
29 29
 
30 30
 #if HAVE_CONFIG_H
31 31
 #include "clamav-config.h"
... ...
@@ -474,7 +474,7 @@ static void
474 474
 help(void)
475 475
 {
476 476
 	printf("\n\tclamav-milter version %s\n", CM_VERSION);
477
-	puts("\tCopyright (C) 2004 Nigel Horne <njh@despammed.com>\n");
477
+	puts("\tCopyright (C) 2006 Nigel Horne <njh@clamav.net>\n");
478 478
 
479 479
 	puts(_("\t--advisory\t\t-A\tFlag viruses rather than deleting them."));
480 480
 	puts(_("\t--bounce\t\t-b\tSend a failure message to the sender."));
... ...
@@ -2561,7 +2561,39 @@ clamfi_body(SMFICTX *ctx, u_char *bodyp, size_t len)
2561 2561
 	if(len == 0)	/* unlikely */
2562 2562
 		return SMFIS_CONTINUE;
2563 2563
 
2564
-	nbytes = clamfi_send(privdata, len, (char *)bodyp);
2564
+	/*
2565
+	 * Lines starting with From are changed to >From, to
2566
+	 *	avoid FP matches in the scanning code, which will speed it up
2567
+	 */
2568
+	if(cli_memstr((char *)bodyp, len, "\nFrom ", 6)) {
2569
+		const char *ptr = bodyp;
2570
+		int left = len;
2571
+
2572
+		nbytes = 0;
2573
+
2574
+		/*
2575
+		 * FIXME: sending one byte at a time down a socket is
2576
+		 *	inefficient
2577
+		 */
2578
+		do
2579
+			if(*ptr == '\n') {
2580
+				if(strncmp(ptr, "\nFrom ", 6) == 0) {
2581
+					nbytes += clamfi_send(privdata, 7, "\n>From ");
2582
+					ptr += 7;
2583
+					left -= 6;
2584
+				} else {
2585
+					nbytes += clamfi_send(privdata, "\n", 1);
2586
+					ptr++;
2587
+					left--;
2588
+				}
2589
+			} else {
2590
+				nbytes += clamfi_send(privdata, *ptr++, 1);
2591
+				left--;
2592
+			}
2593
+		while(left > 0);
2594
+	} else
2595
+		nbytes = clamfi_send(privdata, len, (char *)bodyp);
2596
+
2565 2597
 	if(streamMaxLength > 0L) {
2566 2598
 		if(privdata->numBytes > streamMaxLength) {
2567 2599
 			if(use_syslog) {