Browse code

uuencode failures no longer fatal

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

Nigel Horne authored on 2004/11/27 22:20:21
Showing 3 changed files
... ...
@@ -1,3 +1,10 @@
1
+Sat Nov 27 13:18:42 GMT 2004 (njh)
2
+----------------------------------
3
+ * libclamav:	Assume x-uue is the same as x-uuencode
4
+		If uudecoding fails and other possibilities have been
5
+			registered, don't take the failure as fatal, also try
6
+			the other decoding methods
7
+
1 8
 Sat Nov 27 12:01:03 GMT 2004 (njh)
2 9
 ----------------------------------
3 10
  * libclamav/mbox.c:	Handle RFC822 comments in the commands, e.g.:
... ...
@@ -17,6 +17,9 @@
17 17
  *
18 18
  * Change History:
19 19
  * $Log: mbox.c,v $
20
+ * Revision 1.187  2004/11/27 13:16:56  nigelhorne
21
+ * uuencode failures no longer fatal
22
+ *
20 23
  * Revision 1.186  2004/11/27 11:59:28  nigelhorne
21 24
  * Handle comments in the command part of headers
22 25
  *
... ...
@@ -546,7 +549,7 @@
546 546
  * Compilable under SCO; removed duplicate code with message.c
547 547
  *
548 548
  */
549
-static	char	const	rcsid[] = "$Id: mbox.c,v 1.186 2004/11/27 11:59:28 nigelhorne Exp $";
549
+static	char	const	rcsid[] = "$Id: mbox.c,v 1.187 2004/11/27 13:16:56 nigelhorne Exp $";
550 550
 
551 551
 #if HAVE_CONFIG_H
552 552
 #include "clamav-config.h"
... ...
@@ -1817,28 +1820,12 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
1817 1817
 					if(aMessage == NULL)
1818 1818
 						continue;
1819 1819
 
1820
-					dtype = messageGetDispositionType(aMessage);
1821
-					cptr = messageGetMimeSubtype(aMessage);
1822
-
1823 1820
 					cli_dbgmsg("Mixed message part %d is of type %d\n",
1824 1821
 						i, messageGetMimeType(aMessage));
1825 1822
 
1826 1823
 					switch(messageGetMimeType(aMessage)) {
1827 1824
 					case APPLICATION:
1828
-#if	0
1829
-						/* strict checking... */
1830
-						if((strcasecmp(dtype, "attachment") == 0) ||
1831
-						   (strcasecmp(cptr, "x-msdownload") == 0) ||
1832
-						   (strcasecmp(cptr, "octet-stream") == 0) ||
1833
-						   (strcasecmp(dtype, "octet-stream") == 0))
1834
-							addAttachment = TRUE;
1835
-						else {
1836
-							cli_dbgmsg("Discarded mixed/application not sent as attachment\n");
1837
-							continue;
1838
-						}
1839
-#endif
1840 1825
 						addAttachment = TRUE;
1841
-
1842 1826
 						break;
1843 1827
 					case NOMIME:
1844 1828
 						cli_dbgmsg("No mime headers found in multipart part %d\n", i);
... ...
@@ -1884,18 +1871,18 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
1884 1884
 						assert(messageGetBody(aMessage) != NULL);
1885 1885
 						break;
1886 1886
 					case TEXT:
1887
+						dtype = messageGetDispositionType(aMessage);
1887 1888
 						cli_dbgmsg("Mixed message text part disposition \"%s\"\n",
1888 1889
 							dtype);
1889 1890
 						if(strcasecmp(dtype, "attachment") == 0)
1890 1891
 							addAttachment = TRUE;
1891 1892
 						else if((*dtype == '\0') || (strcasecmp(dtype, "inline") == 0)) {
1892
-							const text *u_line = uuencodeBegin(aMessage);
1893
-
1894 1893
 							if(mainMessage && (mainMessage != messageIn))
1895 1894
 								messageDestroy(mainMessage);
1896 1895
 							mainMessage = NULL;
1896
+							cptr = messageGetMimeSubtype(aMessage);
1897 1897
 							cli_dbgmsg("Mime subtype \"%s\"\n", cptr);
1898
-							if(u_line) {
1898
+							if(uuencodeBegin(aMessage)) {
1899 1899
 								cli_dbgmsg("Found uuencoded message in multipart/mixed text portion\n");
1900 1900
 								messageSetEncoding(aMessage, "x-uuencode");
1901 1901
 								addAttachment = TRUE;
... ...
@@ -2445,6 +2432,10 @@ endOfMessage(const char *line, const char *boundary)
2445 2445
 	len = strlen(boundary);
2446 2446
 	if(strncasecmp(line, boundary, len) != 0)
2447 2447
 		return 0;
2448
+	/*
2449
+	 * Use < rather than == because some broken mails have white
2450
+	 * space after the boundary
2451
+	 */
2448 2452
 	if(strlen(line) < (len + 2))
2449 2453
 		return 0;
2450 2454
 	line = &line[len];
... ...
@@ -17,6 +17,9 @@
17 17
  *
18 18
  * Change History:
19 19
  * $Log: message.c,v $
20
+ * Revision 1.122  2004/11/27 13:16:54  nigelhorne
21
+ * uuencode failures no longer fatal
22
+ *
20 23
  * Revision 1.121  2004/11/26 16:58:52  nigelhorne
21 24
  * Tidy
22 25
  *
... ...
@@ -360,7 +363,7 @@
360 360
  * uuencodebegin() no longer static
361 361
  *
362 362
  */
363
-static	char	const	rcsid[] = "$Id: message.c,v 1.121 2004/11/26 16:58:52 nigelhorne Exp $";
363
+static	char	const	rcsid[] = "$Id: message.c,v 1.122 2004/11/27 13:16:54 nigelhorne Exp $";
364 364
 
365 365
 #if HAVE_CONFIG_H
366 366
 #include "clamav-config.h"
... ...
@@ -442,6 +445,7 @@ static	const	struct	encoding_map {
442 442
 	{	"x-yencode",		YENCODE		},
443 443
 	{	"x-binhex",		BINHEX		},
444 444
 	{	"us-ascii",		NOENCODING	},	/* incorrect */
445
+	{	"x-uue",		UUENCODE	},	/* incorrect */
445 446
 	{	NULL,			NOENCODING	}
446 447
 };
447 448
 
... ...
@@ -1623,9 +1627,13 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
1623 1623
 
1624 1624
 			if(t_line == NULL) {
1625 1625
 				/*cli_warnmsg("UUENCODED attachment is missing begin statement\n");*/
1626
-				(*destroy)(ret);
1626
+				m->uuencode = NULL;
1627 1627
 				m->base64chars = 0;
1628
-				return NULL;
1628
+				if(i == m->numberOfEncTypes - 1) {
1629
+					(*destroy)(ret);
1630
+					return NULL;
1631
+				}
1632
+				continue;
1629 1633
 			}
1630 1634
 
1631 1635
 			filename = cli_strtok(lineGetData(t_line->t_line), 2, " ");