Browse code

Better warning message about PGP attachments not being scanned

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

Nigel Horne authored on 2004/10/04 21:21:11
Showing 3 changed files
... ...
@@ -1,3 +1,9 @@
1
+Mon Oct  4 13:20:17 BST 2004 (njh)
2
+----------------------------------
3
+  * libclamav:		More informative message when scanning PGP encoded
4
+				emails
5
+			PGP encoded emails are now passed through
6
+
1 7
 Mon Oct  4 11:59:02 BST 2004 (njh)
2 8
 ----------------------------------
3 9
   * clamav-milter:	Better SMTP message when virus is found
... ...
@@ -17,6 +17,9 @@
17 17
  *
18 18
  * Change History:
19 19
  * $Log: mbox.c,v $
20
+ * Revision 1.147  2004/10/04 12:18:09  nigelhorne
21
+ * Better warning message about PGP attachments not being scanned
22
+ *
20 23
  * Revision 1.146  2004/10/04 10:52:39  nigelhorne
21 24
  * Better error message on RFC2047 decode error
22 25
  *
... ...
@@ -426,7 +429,7 @@
426 426
  * Compilable under SCO; removed duplicate code with message.c
427 427
  *
428 428
  */
429
-static	char	const	rcsid[] = "$Id: mbox.c,v 1.146 2004/10/04 10:52:39 nigelhorne Exp $";
429
+static	char	const	rcsid[] = "$Id: mbox.c,v 1.147 2004/10/04 12:18:09 nigelhorne Exp $";
430 430
 
431 431
 #if HAVE_CONFIG_H
432 432
 #include "clamav-config.h"
... ...
@@ -594,6 +597,12 @@ static	void	*getURL(struct arg *arg);
594 594
 				 * presence etc. (which also has disappeared
595 595
 				 * in the final version)
596 596
 				 */
597
+#define	ENCRYPTED	13	/*
598
+				 * e.g. RFC2015
599
+				 * Content-Type: multipart/encrypted;
600
+				 * boundary="nextPart1383049.XCRrrar2yq";
601
+				 * protocol="application/pgp-encrypted"
602
+				 */
597 603
 
598 604
 static	const	struct tableinit {
599 605
 	const	char	*key;
... ...
@@ -620,6 +629,7 @@ static	const	struct tableinit {
620 620
 	{	"report",	REPORT		},
621 621
 	{	"appledouble",	APPLEDOUBLE	},
622 622
 	{	"fax-message",	FAX		},
623
+	{	"encrypted",	ENCRYPTED	},
623 624
 	{	NULL,		0		}
624 625
 };
625 626
 
... ...
@@ -1036,10 +1046,10 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
1036 1036
 	if(mainMessage && (messageGetBody(mainMessage) != NULL)) {
1037 1037
 		mime_type mimeType;
1038 1038
 		int subtype;
1039
-		const char *mimeSubtype;
1039
+		const char *mimeSubtype, *boundary;
1040
+		char *protocol;
1040 1041
 		const text *t_line;
1041 1042
 		/*bool isAlternative;*/
1042
-		const char *boundary;
1043 1043
 		message *aMessage;
1044 1044
 
1045 1045
 		cli_dbgmsg("Parsing mail file\n");
... ...
@@ -1139,6 +1149,10 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
1139 1139
 			inMimeHead = 0;
1140 1140
 
1141 1141
 			/*
1142
+			 * Parse the mainMessage object and create an array
1143
+			 * of objects called messages, one for each of the
1144
+			 * multiparts that mainMessage contains
1145
+			 *
1142 1146
 			 * This looks like parseEmailHeaders() - maybe there's
1143 1147
 			 * some duplication of code to be cleaned up
1144 1148
 			 */
... ...
@@ -1333,6 +1347,14 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
1333 1333
 			free((char *)boundary);
1334 1334
 
1335 1335
 			/*
1336
+			 * For multipart/encrypted
1337
+			 */
1338
+			if(tableFind(subtypeTable, mimeSubtype) == ENCRYPTED)
1339
+				protocol = (char *)messageFindArgument(mainMessage, "protocol");
1340
+			else
1341
+				protocol = NULL;
1342
+
1343
+			/*
1336 1344
 			 * We've finished message we're parsing
1337 1345
 			 */
1338 1346
 			if(mainMessage && (mainMessage != messageIn)) {
... ...
@@ -1341,6 +1363,8 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
1341 1341
 			}
1342 1342
 
1343 1343
 			if(multiparts == 0) {
1344
+				if(protocol)
1345
+					free(protocol);
1344 1346
 				if(messages)
1345 1347
 					free(messages);
1346 1348
 				return 2;	/* Nothing to do */
... ...
@@ -1349,6 +1373,12 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
1349 1349
 			cli_dbgmsg("The message has %d parts\n", multiparts);
1350 1350
 			cli_dbgmsg("Find out the multipart type (%s)\n", mimeSubtype);
1351 1351
 
1352
+			/*
1353
+			 * We now have all the parts of the multipart message
1354
+			 * in the messages array:
1355
+			 *	message *messages[multiparts]
1356
+			 * Let's decide what to do with them all
1357
+			 */
1352 1358
 			switch(tableFind(subtypeTable, mimeSubtype)) {
1353 1359
 			case RELATED:
1354 1360
 				cli_dbgmsg("Multipart related handler\n");
... ...
@@ -1704,6 +1734,20 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
1704 1704
 
1705 1705
 				rc = parseEmailBody(messages[htmltextPart], aText, dir, rfc821Table, subtypeTable, options);
1706 1706
 				break;
1707
+			case ENCRYPTED:
1708
+				rc = 0;
1709
+				if(protocol) {
1710
+					if(strcasecmp(protocol, "application/pgp-encrypted") == 0) {
1711
+						/* RFC2015 */
1712
+						cli_warnmsg("PGP encoded attachment not scanned\n");
1713
+						rc = 2;
1714
+					} else
1715
+						cli_warnmsg("Unknown encryption protocol '%s' - report to bugs@clamav.net\n");
1716
+					free(protocol);
1717
+				} else
1718
+					cli_warnmsg("Encryption method missing protocol name - report to bugs@clamav.net\n");
1719
+
1720
+				break;
1707 1721
 			default:
1708 1722
 				/*
1709 1723
 				 * According to section 7.2.6 of RFC1521,
... ...
@@ -17,6 +17,9 @@
17 17
  *
18 18
  * Change History:
19 19
  * $Log: message.c,v $
20
+ * Revision 1.94  2004/10/04 12:18:08  nigelhorne
21
+ * Better warning message about PGP attachments not being scanned
22
+ *
20 23
  * Revision 1.93  2004/10/01 13:49:22  nigelhorne
21 24
  * Minor code tidy
22 25
  *
... ...
@@ -276,7 +279,7 @@
276 276
  * uuencodebegin() no longer static
277 277
  *
278 278
  */
279
-static	char	const	rcsid[] = "$Id: message.c,v 1.93 2004/10/01 13:49:22 nigelhorne Exp $";
279
+static	char	const	rcsid[] = "$Id: message.c,v 1.94 2004/10/04 12:18:08 nigelhorne Exp $";
280 280
 
281 281
 #if HAVE_CONFIG_H
282 282
 #include "clamav-config.h"
... ...
@@ -2288,6 +2291,7 @@ usefulArg(const char *arg)
2288 2288
 	if((strncasecmp(arg, "name", 4) != 0) &&
2289 2289
 	   (strncasecmp(arg, "filename", 8) != 0) &&
2290 2290
 	   (strncasecmp(arg, "boundary", 8) != 0) &&
2291
+	   (strncasecmp(arg, "protocol", 8) != 0) &&
2291 2292
 	   (strncasecmp(arg, "type", 4) != 0)) {
2292 2293
 		cli_dbgmsg("Discarding unwanted argument '%s'\n", arg);
2293 2294
 		return 0;