Browse code

Moved --sign data to private area

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

Nigel Horne authored on 2003/12/28 02:30:33
Showing 3 changed files
... ...
@@ -1,3 +1,8 @@
1
+Sat Dec 27 17:29:30 GMT 2003 (njh)
2
+----------------------------------
3
+  * clamav-devel: Moved --sign data to private area
4
+		(suggestion by Michael Dankov <misha@btrc.ru>)
5
+
1 6
 Wed Dec 24 15:27:22 CET 2003 (tk)
2 7
 ---------------------------------
3 8
   * libclamav: zziplib - fixed a bus error when compiled with the Sun compiler
... ...
@@ -178,6 +178,7 @@ Changes
178 178
 		before return cl_error
179 179
 0.66	13/12/03 Upissue
180 180
 0.66a	22/12/03 Added --sign
181
+0.66b	27/12/03 --sign moved to privdata
181 182
 
182 183
 BUG REPORTS
183 184
 
... ...
@@ -181,9 +181,13 @@
181 181
  *			before return cl_error
182 182
  *	0.66	13/12/03 Upissue
183 183
  *	0.66a	22/12/03 Added --sign
184
+ *	0.66b	27/12/03 --sign moved to privdata
184 185
  *
185 186
  * Change History:
186 187
  * $Log: clamav-milter.c,v $
188
+ * Revision 1.33  2003/12/27 17:28:56  nigelhorne
189
+ * Moved --sign data to private area
190
+ *
187 191
  * Revision 1.32  2003/12/22 14:05:31  nigelhorne
188 192
  * Added --sign option
189 193
  *
... ...
@@ -265,9 +269,9 @@
265 265
  * Revision 1.6  2003/09/28 16:37:23  nigelhorne
266 266
  * Added -f flag use MaxThreads if --max-children not set
267 267
  */
268
-static	char	const	rcsid[] = "$Id: clamav-milter.c,v 1.32 2003/12/22 14:05:31 nigelhorne Exp $";
268
+static	char	const	rcsid[] = "$Id: clamav-milter.c,v 1.33 2003/12/27 17:28:56 nigelhorne Exp $";
269 269
 
270
-#define	CM_VERSION	"0.66a"
270
+#define	CM_VERSION	"0.66b"
271 271
 
272 272
 /*#define	CONFDIR	"/usr/local/etc"*/
273 273
 
... ...
@@ -340,6 +344,8 @@ struct	privdata {
340 340
 				 */
341 341
 	int	dataSocket;	/* Socket to send data to clamd */
342 342
 	char	*filename;	/* Where to store the message in quarantine */
343
+	u_char	*body;		/* body of the message if Sflag is set */
344
+	size_t	bodyLen;	/* number of bytes in body */
343 345
 };
344 346
 
345 347
 static	int	pingServer(void);
... ...
@@ -405,8 +411,6 @@ static	int	threadtimeout = CL_DEFAULT_SCANTIMEOUT; /*
405 405
 				 * number of seconds to wait for clamd to
406 406
 				 * respond
407 407
 				 */
408
-static	u_char	*body;		/* body of the message if Sflag is set */
409
-static	size_t	bodyLen;	/* number of bytes in body */
410 408
 static	const	char	signature[] =	/* TODO: read in from a file */
411 409
 	"-- \nScanned by ClamAv - http://clamav.elektrapro.com\n";
412 410
 
... ...
@@ -1381,16 +1385,16 @@ clamfi_body(SMFICTX *ctx, u_char *bodyp, size_t len)
1381 1381
 		return cl_error;
1382 1382
 	}
1383 1383
 	if(Sflag) {
1384
-		if(body) {
1385
-			assert(bodyLen > 0);
1386
-			body = realloc(body, bodyLen + len);
1387
-			memcpy(&body[bodyLen], bodyp, len);
1388
-			bodyLen += len;
1384
+		if(privdata->body) {
1385
+			assert(privdata->bodyLen > 0);
1386
+			privdata->body = realloc(privdata->body, privdata->bodyLen + len);
1387
+			memcpy(&privdata->body[privdata->bodyLen], bodyp, len);
1388
+			privdata->bodyLen += len;
1389 1389
 		} else {
1390
-			assert(bodyLen == 0);
1391
-			body = malloc(len);
1392
-			memcpy(body, bodyp, len);
1393
-			bodyLen = len;
1390
+			assert(privdata->bodyLen == 0);
1391
+			privdata->body = malloc(len);
1392
+			memcpy(privdata->body, bodyp, len);
1393
+			privdata->bodyLen = len;
1394 1394
 		}
1395 1395
 	}
1396 1396
 	return SMFIS_CONTINUE;
... ...
@@ -1490,13 +1494,13 @@ clamfi_eom(SMFICTX *ctx)
1490 1490
 			syslog(LOG_NOTICE, "clean message from %s",
1491 1491
 				(privdata->from) ? privdata->from : "an unknown sender");
1492 1492
 
1493
-		if(body) {
1493
+		if(privdata->body) {
1494 1494
 			assert(Sflag != 0);
1495 1495
 
1496
-			body = realloc(body, bodyLen + sizeof(signature));
1497
-			memcpy(&body[bodyLen], signature, sizeof(signature));
1496
+			privdata->body = realloc(privdata->body, privdata->bodyLen + sizeof(signature));
1497
+			memcpy(&privdata->body[privdata->bodyLen], signature, sizeof(signature));
1498 1498
 
1499
-			smfi_replacebody(ctx, body, bodyLen + sizeof(signature));
1499
+			smfi_replacebody(ctx, privdata->body, privdata->bodyLen + sizeof(signature));
1500 1500
 
1501 1501
 		}
1502 1502
 	} else {
... ...
@@ -1673,13 +1677,10 @@ clamfi_cleanup(SMFICTX *ctx)
1673 1673
 {
1674 1674
 	struct privdata *privdata = (struct privdata *)smfi_getpriv(ctx);
1675 1675
 
1676
-	if(body) {
1677
-		free(body);
1678
-		body = NULL;
1679
-		bodyLen = 0;
1680
-	}
1681
-
1682 1676
 	if(privdata) {
1677
+		if(privdata->body)
1678
+			free(privdata->body);
1679
+
1683 1680
 		if(privdata->dataSocket >= 0) {
1684 1681
 			close(privdata->dataSocket);
1685 1682
 			privdata->dataSocket = -1;