Browse code

Handle clamd giving up on StreamMaxLength before clamav-milter

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@481 77e5149b-7576-45b1-b177-96237e5ba77b

Nigel Horne authored on 2004/04/09 17:38:22
Showing 3 changed files
... ...
@@ -1,3 +1,7 @@
1
+Fri Apr  9 09:50:52 BST 2004 (njh)
2
+----------------------------------
3
+  * clamav-milter:	Handle clamd giving up on StreamMaxLength too early
4
+
1 5
 Thu Apr  8 14:27:30 BST 2004 (njh)
2 6
 ----------------------------------
3 7
   * clamav-milter:	Removed warning message on FreeBSD5.2
... ...
@@ -316,6 +316,7 @@ Changes
316 316
 0.70g	3/4/04	Error if ReadTimeout is -ve
317 317
 		Honour StreamMaxLength
318 318
 0.70h	8/4/04	Cleanup StreamMaxLength code
319
+0.70i	9/4/04	Handle clamd giving up on StreamMaxLength before clamav-milter
319 320
 
320 321
 BUG REPORTS
321 322
 
... ...
@@ -315,9 +315,14 @@
315 315
  *	0.70g	3/4/04	Error if ReadTimeout is -ve
316 316
  *			Honour StreamMaxLength
317 317
  *	0.70h	8/4/04	Cleanup StreamMaxLength code
318
+ *	0.70i	9/4/04	Handle clamd giving up on StreamMaxLength before
319
+ *			clamav-milter
318 320
  *
319 321
  * Change History:
320 322
  * $Log: clamav-milter.c,v $
323
+ * Revision 1.72  2004/04/09 08:36:53  nigelhorne
324
+ * Handle clamd giving up on StreamMaxLength before clamav-milter
325
+ *
321 326
  * Revision 1.71  2004/04/08 13:14:07  nigelhorne
322 327
  * Code tidy up
323 328
  *
... ...
@@ -516,9 +521,9 @@
516 516
  * Revision 1.6  2003/09/28 16:37:23  nigelhorne
517 517
  * Added -f flag use MaxThreads if --max-children not set
518 518
  */
519
-static	char	const	rcsid[] = "$Id: clamav-milter.c,v 1.71 2004/04/08 13:14:07 nigelhorne Exp $";
519
+static	char	const	rcsid[] = "$Id: clamav-milter.c,v 1.72 2004/04/09 08:36:53 nigelhorne Exp $";
520 520
 
521
-#define	CM_VERSION	"0.70h"
521
+#define	CM_VERSION	"0.70i"
522 522
 
523 523
 /*#define	CONFDIR	"/usr/local/etc"*/
524 524
 
... ...
@@ -1968,6 +1973,16 @@ clamfi_eom(SMFICTX *ctx)
1968 1968
 	sendmailId = smfi_getsymval(ctx, "i");
1969 1969
 
1970 1970
 	if(strstr(mess, "ERROR") != NULL) {
1971
+		if(strstr(mess, "Size exceeded") != NULL) {
1972
+			/*
1973
+			 * Clamd has stopped on StreamMaxLength before us
1974
+			 */
1975
+			if(use_syslog)
1976
+				syslog(LOG_NOTICE, "%s: Message more than StreamMaxLength (%ld) bytes - not scanned\n",
1977
+					sendmailId, streamMaxLength);
1978
+			clamfi_cleanup(ctx);	/* not needed, but just to be safe */
1979
+			return SMFIS_ACCEPT;
1980
+		}
1971 1981
 
1972 1982
 		cli_warnmsg("%s: %s\n", sendmailId, mess);
1973 1983
 		if(use_syslog)
... ...
@@ -2016,10 +2031,9 @@ clamfi_eom(SMFICTX *ctx)
2016 2016
 
2017 2017
 		/*
2018 2018
 		 * Use snprintf rather than printf since we don't know the
2019
-		 * length of privdata->from and may get a buffre overrun
2020
-		 * causing a crash
2019
+		 * length of privdata->from and may get a buffer overrun
2021 2020
 		 */
2022
-		snprintf(err, 1024, "Intercepted virus from %s to",
2021
+		snprintf(err, 1023, "Intercepted virus from %s to",
2023 2022
 			privdata->from);
2024 2023
 
2025 2024
 		ptr = strchr(err, '\0');
... ...
@@ -2503,7 +2517,7 @@ header_list_add(header_list_t list, const char *headerf, const char *headerv)
2503 2503
 	len = strlen(headerf) + strlen(headerv) + 3;
2504 2504
 
2505 2505
 	header = (char *)cli_malloc(len);
2506
-	snprintf(header, len, "%s: %s", headerf, headerv);
2506
+	sprintf(header, "%s: %s", headerf, headerv);
2507 2507
 	new_node = (struct header_node_t *)cli_malloc(sizeof(struct header_node_t));
2508 2508
 	new_node->header = header;
2509 2509
 	new_node->next = NULL;