Browse code

Removed handling for non fast tracked uuencoded messages

git-svn: trunk@1488

Nigel Horne authored on 2005/04/21 20:13:41
Showing 4 changed files
... ...
@@ -1,3 +1,9 @@
1
+Thu Apr 21 12:12:29 BST 2005 (njh)
2
+----------------------------------
3
+  * libclamav:		Removed the support for non fast-tracked uuencoded
4
+				messages. All uuencoded messages are now
5
+				handled by the fast track visa system
6
+
1 7
 Wed Apr 20 01:50:36 CEST 2005 (tk)
2 8
 ----------------------------------
3 9
   * libclamav/pe.c: Add more machine types (thanks to Christoph)
... ...
@@ -38,7 +44,7 @@ Thu Apr 14 14:35:37 BST 2005 (trog)
38 38
   * libclamav/unrar.c, unrar.h, unrarvm.h: update code for activation
39 39
 
40 40
   * libclamav/Makefile.am, Makefile.in: compile in new RAR code
41
- 
41
+
42 42
 Thu Apr 14 14:11:31 CEST 2005 (tk)
43 43
 ----------------------------------
44 44
   * freshclam/manager.c: pass proper argument to OnErrorExecute (patch by
... ...
@@ -15,7 +15,7 @@
15 15
  *  along with this program; if not, write to the Free Software
16 16
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 17
  */
18
-static	char	const	rcsid[] = "$Id: mbox.c,v 1.238 2005/04/19 09:20:55 nigelhorne Exp $";
18
+static	char	const	rcsid[] = "$Id: mbox.c,v 1.239 2005/04/21 11:12:06 nigelhorne Exp $";
19 19
 
20 20
 #if HAVE_CONFIG_H
21 21
 #include "clamav-config.h"
... ...
@@ -1537,19 +1537,11 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
1537 1537
 					if(boundaryStart(lineGetData(t_line->t_line), boundary))
1538 1538
 						break;
1539 1539
 					/*
1540
-					 * Found a uuencoded/binhex file before
1540
+					 * Found a binhex file before
1541 1541
 					 *	the first multipart
1542 1542
 					 * TODO: check yEnc
1543 1543
 					 */
1544
-					if(uuencodeBegin(mainMessage) == t_line) {
1545
-						if(messageGetEncoding(mainMessage) == NOENCODING) {
1546
-							messageSetEncoding(mainMessage, "x-uuencode");
1547
-							fb = messageToFileblob(mainMessage, dir);
1548
-
1549
-							if(fb)
1550
-								fileblobDestroy(fb);
1551
-						}
1552
-					} else if(binhexBegin(mainMessage) == t_line) {
1544
+					if(binhexBegin(mainMessage) == t_line) {
1553 1545
 						if(messageGetEncoding(mainMessage) == NOENCODING) {
1554 1546
 							messageSetEncoding(mainMessage, "x-binhex");
1555 1547
 							fb = messageToFileblob(mainMessage, dir);
... ...
@@ -1584,7 +1576,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
1584 1584
 				mimeType = NOMIME;
1585 1585
 				/*
1586 1586
 				 * The break means that we will still
1587
-				 * check if the file contains a uuencoded file
1587
+				 * check if the file contains a yEnc/binhex file
1588 1588
 				 */
1589 1589
 				break;
1590 1590
 			}
... ...
@@ -1635,12 +1627,12 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
1635 1635
 					cli_dbgmsg("Empty part\n");
1636 1636
 					/*
1637 1637
 					 * Remove this part unless there's
1638
-					 * a uuencoded portion somewhere in
1638
+					 * a binhex portion somewhere in
1639 1639
 					 * the complete message that we may
1640 1640
 					 * throw away by mistake if the MIME
1641 1641
 					 * encoding information is incorrect
1642 1642
 					 */
1643
-					if(uuencodeBegin(mainMessage) == NULL) {
1643
+					if(binhexBegin(mainMessage) == NULL) {
1644 1644
 						messageDestroy(aMessage);
1645 1645
 						--multiparts;
1646 1646
 					}
... ...
@@ -2028,9 +2020,9 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2028 2028
 					case NOMIME:
2029 2029
 						cli_dbgmsg("No mime headers found in multipart part %d\n", i);
2030 2030
 						if(mainMessage) {
2031
-							if(uuencodeBegin(aMessage)) {
2032
-								cli_dbgmsg("Found uuencoded message in multipart/mixed mainMessage\n");
2033
-								messageSetEncoding(mainMessage, "x-uuencode");
2031
+							if(binhexBegin(aMessage)) {
2032
+								cli_dbgmsg("Found binhex message in multipart/mixed mainMessage\n");
2033
+								messageSetEncoding(mainMessage, "x-bunhex");
2034 2034
 								fb = messageToFileblob(mainMessage, dir);
2035 2035
 
2036 2036
 								if(fb)
... ...
@@ -2040,16 +2032,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2040 2040
 								messageDestroy(mainMessage);
2041 2041
 							mainMessage = NULL;
2042 2042
 						} else if(aMessage) {
2043
-							if(uuencodeBegin(aMessage)) {
2044
-								cli_dbgmsg("Found uuencoded message in multipart/mixed non mime part\n");
2045
-								messageSetEncoding(aMessage, "x-uuencode");
2046
-								fb = messageToFileblob(aMessage, dir);
2047
-
2048
-								if(fb)
2049
-									fileblobDestroy(fb);
2050
-								assert(aMessage == messages[i]);
2051
-								messageReset(messages[i]);
2052
-							} else if(binhexBegin(aMessage)) {
2043
+							if(binhexBegin(aMessage)) {
2053 2044
 								cli_dbgmsg("Found binhex message in multipart/mixed non mime part\n");
2054 2045
 								messageSetEncoding(aMessage, "x-binhex");
2055 2046
 								fb = messageToFileblob(aMessage, dir);
... ...
@@ -2080,10 +2063,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2080 2080
 							mainMessage = NULL;
2081 2081
 							cptr = messageGetMimeSubtype(aMessage);
2082 2082
 							cli_dbgmsg("Mime subtype \"%s\"\n", cptr);
2083
-							if(uuencodeBegin(aMessage)) {
2084
-								cli_dbgmsg("Found uuencoded message in multipart/mixed text portion\n");
2085
-								messageSetEncoding(aMessage, "x-uuencode");
2086
-							} else if((tableFind(subtypeTable, cptr) == PLAIN) &&
2083
+							if((tableFind(subtypeTable, cptr) == PLAIN) &&
2087 2084
 								  (messageGetEncoding(aMessage) == NOENCODING)) {
2088 2085
 								char *filename;
2089 2086
 								/*
... ...
@@ -2517,21 +2497,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2517 2517
 		 */
2518 2518
 		const text *t_line;
2519 2519
 
2520
-		if((t_line = uuencodeBegin(mainMessage)) != NULL) {
2521
-			cli_dbgmsg("Found uuencoded file\n");
2522
-
2523
-			/*
2524
-			 * Main part contains uuencoded section
2525
-			 */
2526
-			messageSetEncoding(mainMessage, "x-uuencode");
2527
-
2528
-			if((fb = messageToFileblob(mainMessage, dir)) != NULL) {
2529
-				if((cptr = fileblobGetFilename(fb)) != NULL)
2530
-					cli_dbgmsg("Saving uuencoded message %s\n", cptr);
2531
-				fileblobDestroy(fb);
2532
-			}
2533
-			rc = 1;
2534
-		} else if((encodingLine(mainMessage) != NULL) &&
2520
+		if((encodingLine(mainMessage) != NULL) &&
2535 2521
 			  ((t_line = bounceBegin(mainMessage)) != NULL)) {
2536 2522
 			const text *t, *start;
2537 2523
 			/*
... ...
@@ -2596,8 +2562,6 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2596 2596
 		} else {
2597 2597
 			bool saveIt;
2598 2598
 
2599
-			cli_dbgmsg("Not found uuencoded file\n");
2600
-
2601 2599
 			if(messageGetMimeType(mainMessage) == MESSAGE)
2602 2600
 				/*
2603 2601
 				 * Quick peek, if the encapsulated
... ...
@@ -3925,7 +3889,7 @@ getline(char *buffer, size_t len, FILE *fin)
3925 3925
 	} while(--len > 0);
3926 3926
 
3927 3927
 	if(len == 0) {
3928
-		/* probably, the email breaks RFC821 */
3928
+		/* the email probably breaks RFC821 */
3929 3929
 		cli_dbgmsg("getline: buffer overflow stopped\n");
3930 3930
 		return NULL;
3931 3931
 	}
... ...
@@ -15,7 +15,7 @@
15 15
  *  along with this program; if not, write to the Free Software
16 16
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 17
  */
18
-static	char	const	rcsid[] = "$Id: message.c,v 1.152 2005/03/28 11:03:15 nigelhorne Exp $";
18
+static	char	const	rcsid[] = "$Id: message.c,v 1.153 2005/04/21 11:12:06 nigelhorne Exp $";
19 19
 
20 20
 #if HAVE_CONFIG_H
21 21
 #include "clamav-config.h"
... ...
@@ -712,6 +712,13 @@ messageSetEncoding(message *m, const char *enctype)
712 712
 				 */
713 713
 				continue;
714 714
 
715
+			if(strcmp(e->string, "uuencode") == 0)
716
+				/*
717
+				 * No need to test here - fast track visa will have
718
+				 * handled uuencoded files
719
+				 */
720
+				continue;
721
+
715 722
 			sim = simil(type, e->string);
716 723
 
717 724
 			if(sim == 100) {
... ...
@@ -949,8 +956,9 @@ messageIsEncoding(message *m)
949 949
 		(strncasecmp(line, "Received: ", 10) == 0) &&
950 950
 		(cli_filetype(line, strlen(line)) == CL_TYPE_MAIL))
951 951
 			m->bounce = m->body_last;
952
-	else if((m->uuencode == NULL) && isuuencodebegin(line))
953
-		m->uuencode = m->body_last;
952
+		/* Not needed with fast track visa technology */
953
+	/*else if((m->uuencode == NULL) && isuuencodebegin(line))
954
+		m->uuencode = m->body_last;*/
954 955
 	else if((m->binhex == NULL) &&
955 956
 		strstr(line, "BinHex") &&
956 957
 		(simil(line, binhex) > 90))
... ...
@@ -1305,12 +1313,8 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
1305 1305
 		if(filename)
1306 1306
 			free((char *)filename);
1307 1307
 
1308
-		if(m->numberOfEncTypes == 0) {
1309
-			if(uuencodeBegin(m))
1310
-				messageSetEncoding(m, "x-uuencode");
1311
-			else
1312
-				return exportText(messageGetBody(m), ret);
1313
-		}
1308
+		if(m->numberOfEncTypes == 0)
1309
+			return exportText(messageGetBody(m), ret);
1314 1310
 	}
1315 1311
 
1316 1312
 	for(i = 0; i < m->numberOfEncTypes; i++) {
... ...
@@ -1332,36 +1336,7 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
1332 1332
 		/*
1333 1333
 		 * Find the filename to decode
1334 1334
 		 */
1335
-		if((enctype == UUENCODE) || uuencodeBegin(m)) {
1336
-			t_line = uuencodeBegin(m);
1337
-
1338
-			if(t_line == NULL) {
1339
-				/*cli_warnmsg("UUENCODED attachment is missing begin statement\n");*/
1340
-				m->uuencode = NULL;
1341
-				m->base64chars = 0;
1342
-				if(i == m->numberOfEncTypes - 1) {
1343
-					(*destroy)(ret);
1344
-					return NULL;
1345
-				}
1346
-				continue;
1347
-			}
1348
-
1349
-			filename = cli_strtok(lineGetData(t_line->t_line), 2, " ");
1350
-
1351
-			if(filename == NULL) {
1352
-				cli_dbgmsg("UUencoded attachment sent with no filename\n");
1353
-				(*destroy)(ret);
1354
-				return NULL;
1355
-			}
1356
-			cli_chomp(filename);
1357
-
1358
-			cli_dbgmsg("Set uuencode filename to \"%s\"\n", filename);
1359
-
1360
-			(*setFilename)(ret, dir, filename);
1361
-			t_line = t_line->t_next;
1362
-			enctype = UUENCODE;
1363
-			m->uuencode = NULL;
1364
-		} else if(((enctype == YENCODE) && yEncBegin(m)) || ((i == 0) && yEncBegin(m))) {
1335
+		if(((enctype == YENCODE) && yEncBegin(m)) || ((i == 0) && yEncBegin(m))) {
1365 1336
 			/*
1366 1337
 			 * TODO: handle multipart yEnc encoded files
1367 1338
 			 */
... ...
@@ -1386,6 +1361,15 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
1386 1386
 			enctype = YENCODE;
1387 1387
 			m->yenc = NULL;
1388 1388
 		} else {
1389
+			if(enctype == UUENCODE) {
1390
+				/*
1391
+				 * The body will have been stripped out by the fast track visa
1392
+				 * system. Treat as plain/text, which means we'll still scan
1393
+				 * for funnies outside of the uuencoded portion.
1394
+				 */
1395
+				cli_dbgmsg("messageExport: treat uuencode as text/plain");
1396
+				enctype = m->encodingTypes[i] = NOENCODING;
1397
+			}
1389 1398
 			filename = (char *)messageFindArgument(m, "filename");
1390 1399
 			if(filename == NULL) {
1391 1400
 				filename = (char *)messageFindArgument(m, "name");
... ...
@@ -1397,6 +1381,8 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
1397 1397
 					/*
1398 1398
 					 * Some virus attachments don't say how they've
1399 1399
 					 * been encoded. We assume base64
1400
+					 *
1401
+					 * FIXME: don't do this if it's a fall through from uuencode
1400 1402
 					 */
1401 1403
 					messageSetEncoding(m, "base64");
1402 1404
 			}
... ...
@@ -1435,16 +1421,7 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
1435 1435
 			unsigned char *bigbuf;
1436 1436
 			size_t datasize;
1437 1437
 
1438
-			if(enctype == UUENCODE) {
1439
-				/*
1440
-				 * There should be no blank lines in uuencoded
1441
-				 * files...
1442
-				 */
1443
-				if(line == NULL)
1444
-					continue;
1445
-				if(strcasecmp(line, "end") == 0)
1446
-					break;
1447
-			} else if(enctype == YENCODE) {
1438
+			if(enctype == YENCODE) {
1448 1439
 				if(line == NULL)
1449 1440
 					continue;
1450 1441
 				if(strncmp(line, "=yend ", 6) == 0)
... ...
@@ -1612,19 +1589,12 @@ messageToText(message *m)
1612 1612
 				}
1613 1613
 				continue;
1614 1614
 			case UUENCODE:
1615
-				t_line = uuencodeBegin(m);
1616
-
1617
-				if(t_line == NULL) {
1618
-					/*cli_warnmsg("UUENCODED attachment is missing begin statement\n");*/
1619
-					if(first) {
1620
-						last->t_next = NULL;
1621
-						textDestroy(first);
1622
-					}
1623
-					return NULL;
1615
+				cli_errmsg("messageToText: Unexpected attempt to handle uuencoded file - report to bugs@clamav.net\n");
1616
+				if(first) {
1617
+					last->t_next = NULL;
1618
+					textDestroy(first);
1624 1619
 				}
1625
-				t_line = t_line->t_next;
1626
-				m->uuencode = NULL;
1627
-				break;
1620
+				return NULL;
1628 1621
 			case YENCODE:
1629 1622
 				t_line = yEncBegin(m);
1630 1623
 
... ...
@@ -1648,16 +1618,13 @@ messageToText(message *m)
1648 1648
 			unsigned char *uptr;
1649 1649
 			const char *line = lineGetData(t_line->t_line);
1650 1650
 
1651
-			if(enctype == BASE64) {
1651
+			if(enctype == BASE64)
1652 1652
 				/*
1653 1653
 				 * ignore blanks - breaks RFC which is
1654 1654
 				 * probably the point!
1655 1655
 				 */
1656 1656
 				if(line == NULL)
1657 1657
 					continue;
1658
-			} else if(enctype == UUENCODE)
1659
-				if(strcasecmp(line, "end") == 0)
1660
-					break;
1661 1658
 
1662 1659
 			assert((line == NULL) || (strlen(line) <= sizeof(data)));
1663 1660
 
... ...
@@ -1726,34 +1693,6 @@ messageToText(message *m)
1726 1726
 	return first;
1727 1727
 }
1728 1728
 
1729
-/*
1730
- * Scan to find the UUENCODED message (if any)
1731
- */
1732
-#if	0
1733
-const text *
1734
-uuencodeBegin(const message *m)
1735
-{
1736
-	const text *t_line;
1737
-
1738
-	/*
1739
-	 * Fix based on an idea by Magnus Jonsson
1740
-	 * <Magnus.Jonsson@umdac.umu.se>, to allow for blank
1741
-	 * lines before the begin. Should not happen, but some
1742
-	 * e-mail clients are rather broken...
1743
-	 */
1744
-	for(t_line = messageGetBody(m); t_line; t_line = t_line->t_next)
1745
-		if(isuuencodebegin(t_line->t_text))
1746
-			return t_line;
1747
-	return NULL;
1748
-}
1749
-#else
1750
-const text *
1751
-uuencodeBegin(const message *m)
1752
-{
1753
-	return m->uuencode;
1754
-}
1755
-#endif
1756
-
1757 1729
 const text *
1758 1730
 yEncBegin(const message *m)
1759 1731
 {
... ...
@@ -1842,7 +1781,7 @@ encodingLine(const message *m)
1842 1842
 void
1843 1843
 messageClearMarkers(message *m)
1844 1844
 {
1845
-	m->encoding = m->bounce = m->uuencode = m->binhex = NULL;
1845
+	m->encoding = m->bounce = m->binhex = NULL;
1846 1846
 }
1847 1847
 
1848 1848
 /*
... ...
@@ -2330,8 +2269,6 @@ messageDedup(message *m)
2330 2330
 			continue;
2331 2331
 		if(t1 == m->bounce)
2332 2332
 			continue;
2333
-		if(t1 == m->uuencode)
2334
-			continue;
2335 2333
 		if(t1 == m->binhex)
2336 2334
 			continue;
2337 2335
 		if(t1 == m->yenc)
... ...
@@ -2640,6 +2577,9 @@ pop(LINK1 *top, char *buffer)
2640 2640
 int
2641 2641
 isuuencodebegin(const char *line)
2642 2642
 {
2643
+	if(line[0] != 'b')	/* quick check */
2644
+		return 0;
2645
+
2643 2646
 	if(strlen(line) < 10)
2644 2647
 		return 0;
2645 2648
 
... ...
@@ -37,7 +37,6 @@ typedef struct message {
37 37
 	 */
38 38
 	const text	*bounce;	/* start of a bounced message */
39 39
 	const text	*binhex;	/* start of a binhex message */
40
-	const text	*uuencode;	/* start of a uuencoded message */
41 40
 	const text	*yenc;		/* start of a yEnc message */
42 41
 	const text	*encoding;	/* is the non MIME message encoded? */
43 42
 	const text	*dedupedThisFar;
... ...
@@ -66,7 +65,6 @@ fileblob	*messageToFileblob(message *m, const char *dir);
66 66
 blob	*messageToBlob(message *m);
67 67
 text	*messageToText(message *m);
68 68
 const	text	*binhexBegin(const message *m);
69
-const	text	*uuencodeBegin(const message *m);
70 69
 const	text	*yEncBegin(const message *m);
71 70
 const	text	*bounceBegin(const message *m);
72 71
 const	text	*encodingLine(const message *m);