Browse code

More tidy approach to allocating the per-message area

git-svn: trunk@2208

Nigel Horne authored on 2006/08/25 22:12:00
Showing 2 changed files
... ...
@@ -1,3 +1,8 @@
1
+Fri Aug 25 14:11:05 BST 2006 (njh)
2
+----------------------------------
3
+  * clamav-milter:	Fix a problem with multiple messages on the same
4
+				connexion introduced earlier today
5
+
1 6
 Fri Aug 25 11:22:24 BST 2006 (njh)
2 7
 ----------------------------------
3 8
   * clamav-milter:	Start a separate thread for each load balancing server
... ...
@@ -23,7 +23,7 @@
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.281 2006/08/25 10:21:54 njh Exp $";
26
+static	char	const	rcsid[] = "$Id: clamav-milter.c,v 1.282 2006/08/25 13:09:58 njh Exp $";
27 27
 
28 28
 #define	CM_VERSION	"devel-250806"
29 29
 
... ...
@@ -2514,6 +2514,12 @@ clamfi_connect(SMFICTX *ctx, char *hostname, _SOCK_ADDR *hostaddr)
2514 2514
 	if(privdata == NULL)
2515 2515
 		return cl_error;
2516 2516
 
2517
+#ifdef	SESSION
2518
+	privdata->dataSocket = -1;
2519
+#else
2520
+	privdata->dataSocket = privdata->cmdSocket = -1;
2521
+#endif
2522
+
2517 2523
 	if(smfi_setpriv(ctx, privdata) == MI_SUCCESS) {
2518 2524
 		strcpy(privdata->ip, remoteIP);
2519 2525
 		return SMFIS_CONTINUE;
... ...
@@ -2560,10 +2566,17 @@ clamfi_envfrom(SMFICTX *ctx, char **argv)
2560 2560
 
2561 2561
 	if(privdata == NULL) {
2562 2562
 		/* More than one message on this connection */
2563
+		/* FIXME: if the last one sent a virus we should blacklist */
2563 2564
 		privdata = (struct privdata *)cli_calloc(1, sizeof(struct privdata));
2564 2565
 		if(privdata == NULL)
2565 2566
 			return cl_error;
2566 2567
 
2568
+#ifdef	SESSION
2569
+		privdata->dataSocket = -1;
2570
+#else
2571
+		privdata->dataSocket = privdata->cmdSocket = -1;
2572
+#endif
2573
+
2567 2574
 		if(smfi_setpriv(ctx, privdata) != MI_SUCCESS) {
2568 2575
 			free(privdata);
2569 2576
 			return cl_error;
... ...
@@ -2653,11 +2666,6 @@ clamfi_envfrom(SMFICTX *ctx, char **argv)
2653 2653
 		}
2654 2654
 	}
2655 2655
 
2656
-	privdata->dataSocket = -1;	/* 0.4 */
2657
-#ifndef	SESSION
2658
-	privdata->cmdSocket = -1;	/* 0.4 */
2659
-#endif
2660
-
2661 2656
 	/*
2662 2657
 	 * Rejection is via 550 until DATA is received. We know that
2663 2658
 	 * DATA has been sent when either we get a header or the end of
... ...
@@ -3903,11 +3911,11 @@ clamfi_send(struct privdata *privdata, size_t len, const char *format, ...)
3903 3903
 #ifdef HAVE_STRERROR_R
3904 3904
 					char buf[32];
3905 3905
 					strerror_r(errno, buf, sizeof(buf));
3906
-					syslog(LOG_ERR,
3907
-						_("write failure (%u bytes) to clamd: %s"),
3906
+					logg(_("!write failure (%u bytes) to clamd: %s\n"),
3908 3907
 						len, buf);
3909 3908
 #else
3910
-					syslog(LOG_ERR, _("write failure (%u bytes) to clamd: %s"), len, strerror(errno));
3909
+					logg(_("!write failure (%u bytes) to clamd: %s\n"),
3910
+						len, strerror(errno));
3911 3911
 #endif
3912 3912
 				}
3913 3913
 				checkClamd();