Browse code

Handle hand crafted emails that incorrectly set multipart headers

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

Nigel Horne authored on 2003/12/06 13:05:18
Showing 2 changed files
... ...
@@ -1,3 +1,8 @@
1
+Sat Dec  6 04:04:00 GMT 2003 (njh)
2
+----------------------------------
3
+  * libclamav: Handle hand crafted emails that incorrectly set multipart headers
4
+  	Handcrafted examples sent by Michael Dankov <misha@btrc.ru>
5
+
1 6
 Sat Dec  6 00:43:08 CET 2003 (tk)
2 7
 ---------------------------------
3 8
   * Applied a patch from David S. Madole <david*madole.net>:
... ...
@@ -17,6 +17,9 @@
17 17
  *
18 18
  * Change History:
19 19
  * $Log: mbox.c,v $
20
+ * Revision 1.20  2003/12/06 04:03:26  nigelhorne
21
+ * Handle hand crafted emails that incorrectly set multipart headers
22
+ *
20 23
  * Revision 1.19  2003/11/21 07:26:31  nigelhorne
21 24
  * Scan multipart alternatives that have no boundaries, finds some uuencoded happy99
22 25
  *
... ...
@@ -48,15 +51,17 @@
48 48
  * Compilable under SCO; removed duplicate code with message.c
49 49
  *
50 50
  */
51
-static	char	const	rcsid[] = "$Id: mbox.c,v 1.19 2003/11/21 07:26:31 nigelhorne Exp $";
51
+static	char	const	rcsid[] = "$Id: mbox.c,v 1.20 2003/12/06 04:03:26 nigelhorne Exp $";
52 52
 
53 53
 #ifndef	CL_DEBUG
54 54
 /*#define	NDEBUG	/* map CLAMAV debug onto standard */
55 55
 #endif
56 56
 
57 57
 #ifdef CL_THREAD_SAFE
58
+#ifndef	_REENTRANT
58 59
 #define	_REENTRANT	/* for Solaris 2.8 */
59 60
 #endif
61
+#endif
60 62
 
61 63
 #include <stdio.h>
62 64
 #include <stdlib.h>
... ...
@@ -453,7 +458,7 @@ insert(message *mainMessage, blob **blobsIn, int nBlobs, text *textIn, const cha
453 453
 		mime_type mimeType;
454 454
 		const char *mimeSubtype;
455 455
 		const text *t_line;
456
-		bool isAlternative;
456
+		/*bool isAlternative;*/
457 457
 		const char *boundary;
458 458
 		message *aMessage;
459 459
 #ifdef CL_THREAD_SAFE
... ...
@@ -582,7 +587,7 @@ insert(message *mainMessage, blob **blobsIn, int nBlobs, text *textIn, const cha
582 582
 							cli_dbgmsg("insert content-type: parse line '%s'\n", line);
583 583
 							arg = strtok_r(NULL, "\r\n", &strptr);
584 584
 							if((arg == NULL) || (strchr(arg, '/') == NULL)) {
585
-								if(arg == NULL) 
585
+								if(arg == NULL)
586 586
 									cli_warnmsg("Empty content-type received, assuming text/plain; charset=us-ascii\n", arg);
587 587
 								else
588 588
 									cli_warnmsg("Invalid content-type '%s' received, no subtype specified, assuming text/plain; charset=us-ascii\n", arg);
... ...
@@ -713,13 +718,20 @@ insert(message *mainMessage, blob **blobsIn, int nBlobs, text *textIn, const cha
713 713
 				 * Content-Type: multipart/related;
714 714
 				 *	type="multipart/alternative"
715 715
 				 */
716
-				cptr = messageFindArgument(mainMessage, "type");
716
+				/*
717
+				 * Changed to always fall through based on
718
+				 * an idea from Michael Dankov <misha@btrc.ru>
719
+				 * that some viruses are completely confused
720
+				 * about the difference between related
721
+				 * and mixed
722
+				 */
723
+				/*cptr = messageFindArgument(mainMessage, "type");
717 724
 				if(cptr == NULL)
718 725
 					break;
719 726
 				isAlternative = (bool)(strcasecmp(cptr, "multipart/alternative") == 0);
720 727
 				free((char *)cptr);
721 728
 				if(!isAlternative)
722
-					break;
729
+					break;*/
723 730
 			case ALTERNATIVE:
724 731
 				cli_dbgmsg("Multipart alternative handler\n");
725 732
 
... ...
@@ -1504,7 +1516,7 @@ saveFile(const blob *b, const char *dir)
1504 1504
 	 * Allow for very long filenames. We have to truncate them to fit
1505 1505
 	 */
1506 1506
 	snprintf(filename, sizeof(filename) - 1 - len, "%s/%.*sXXXXXX", dir,
1507
-		sizeof(filename) - 9 - len - strlen(dir), cptr);
1507
+		(int)(sizeof(filename) - 9 - len - strlen(dir)), cptr);
1508 1508
 
1509 1509
 	/*
1510 1510
 	 * TODO: add a HAVE_MKSTEMP property