Browse code

Handle spaces after the final MIME boundary and binHex attachments after that boundary

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

Nigel Horne authored on 2004/11/27 08:01:53
Showing 2 changed files
... ...
@@ -1,3 +1,9 @@
1
+Fri Nov 26 23:00:42 GMT 2004 (njh)
2
+----------------------------------
3
+ * libclamav/mbox.c:	Scan binHexes after the final MIME section
4
+			Handle spaces incorrectly added to the final MIME
5
+				section marker
6
+
1 7
 Fri Nov 26 21:53:03 GMT 2004 (njh)
2 8
 ----------------------------------
3 9
  * libclamav/mbox.c:	Scan uuencodes after the final MIME section
... ...
@@ -17,6 +17,9 @@
17 17
  *
18 18
  * Change History:
19 19
  * $Log: mbox.c,v $
20
+ * Revision 1.185  2004/11/26 23:00:29  nigelhorne
21
+ * Handle spaces after the final MIME boundary and binHex attachments after that boundary
22
+ *
20 23
  * Revision 1.184  2004/11/26 21:51:48  nigelhorne
21 24
  * Scan uuencodes after the final MIME section
22 25
  *
... ...
@@ -540,7 +543,7 @@
540 540
  * Compilable under SCO; removed duplicate code with message.c
541 541
  *
542 542
  */
543
-static	char	const	rcsid[] = "$Id: mbox.c,v 1.184 2004/11/26 21:51:48 nigelhorne Exp $";
543
+static	char	const	rcsid[] = "$Id: mbox.c,v 1.185 2004/11/26 23:00:29 nigelhorne Exp $";
544 544
 
545 545
 #if HAVE_CONFIG_H
546 546
 #include "clamav-config.h"
... ...
@@ -1459,7 +1462,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
1459 1459
 				do {
1460 1460
 					const char *line = lineGetData(t_line->t_line);
1461 1461
 
1462
-					/*printf("inMimeHead %d inhead %d boundary %s line '%s' next '%s'\n",
1462
+					/*printf("inMimeHead %d inhead %d boundary '%s' line '%s' next '%s'\n",
1463 1463
 						inMimeHead, inhead, boundary, line,
1464 1464
 						t_line->t_next && t_line->t_next->t_line ? lineGetData(t_line->t_next->t_line) : "(null)");*/
1465 1465
 
... ...
@@ -1832,8 +1835,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
1832 1832
 					case NOMIME:
1833 1833
 						cli_dbgmsg("No mime headers found in multipart part %d\n", i);
1834 1834
 						if(mainMessage) {
1835
-							const text *u_line = uuencodeBegin(mainMessage);
1836
-							if(u_line) {
1835
+							if(uuencodeBegin(aMessage)) {
1837 1836
 								cli_dbgmsg("Found uuencoded message in multipart/mixed mainMessage\n");
1838 1837
 								messageSetEncoding(mainMessage, "x-uuencode");
1839 1838
 								fb = messageToFileblob(mainMessage, dir);
... ...
@@ -1845,8 +1847,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
1845 1845
 								messageDestroy(mainMessage);
1846 1846
 							mainMessage = NULL;
1847 1847
 						} else if(aMessage) {
1848
-							const text *u_line = uuencodeBegin(aMessage);
1849
-							if(u_line) {
1848
+							if(uuencodeBegin(aMessage)) {
1850 1849
 								cli_dbgmsg("Found uuencoded message in multipart/mixed non mime part\n");
1851 1850
 								messageSetEncoding(aMessage, "x-uuencode");
1852 1851
 								fb = messageToFileblob(aMessage, dir);
... ...
@@ -1855,6 +1856,15 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
1855 1855
 									fileblobDestroy(fb);
1856 1856
 								assert(aMessage == messages[i]);
1857 1857
 								messageReset(messages[i]);
1858
+							} else if(binhexBegin(aMessage)) {
1859
+								cli_dbgmsg("Found binhex message in multipart/mixed non mime part\n");
1860
+								messageSetEncoding(aMessage, "x-binhex");
1861
+								fb = messageToFileblob(aMessage, dir);
1862
+
1863
+								if(fb)
1864
+									fileblobDestroy(fb);
1865
+								assert(aMessage == messages[i]);
1866
+								messageReset(messages[i]);
1858 1867
 							}
1859 1868
 						}
1860 1869
 						addToText = TRUE;
... ...
@@ -2427,7 +2437,7 @@ endOfMessage(const char *line, const char *boundary)
2427 2427
 	len = strlen(boundary);
2428 2428
 	if(strncasecmp(line, boundary, len) != 0)
2429 2429
 		return 0;
2430
-	if(strlen(line) != (len + 2))
2430
+	if(strlen(line) < (len + 2))
2431 2431
 		return 0;
2432 2432
 	line = &line[len];
2433 2433
 	if(*line++ != '-')