Browse code

If a message only contains a single RFC822 message that has no encoding don't save for scanning

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

Nigel Horne authored on 2004/03/19 06:52:51
Showing 3 changed files
... ...
@@ -1,3 +1,8 @@
1
+Thu Mar 18 22:01:39 GMT 2004 (njh)
2
+----------------------------------
3
+  * libclamav:	If a message only contains a single RFC822 message that has no
4
+	encoding don't save for scanning
5
+
1 6
 Thu Mar 18 14:16:19 GMT 2004 (njh)
2 7
 ----------------------------------
3 8
   * libclamav/message.c:	Added bounce and handle text/plain encoded
... ...
@@ -17,6 +17,9 @@
17 17
  *
18 18
  * Change History:
19 19
  * $Log: mbox.c,v $
20
+ * Revision 1.52  2004/03/18 21:51:41  nigelhorne
21
+ * If a message only contains a single RFC822 message that has no encoding don't save for scanning
22
+ *
20 23
  * Revision 1.51  2004/03/17 19:48:12  nigelhorne
21 24
  * Improved embedded RFC822 message handling
22 25
  *
... ...
@@ -144,7 +147,7 @@
144 144
  * Compilable under SCO; removed duplicate code with message.c
145 145
  *
146 146
  */
147
-static	char	const	rcsid[] = "$Id: mbox.c,v 1.51 2004/03/17 19:48:12 nigelhorne Exp $";
147
+static	char	const	rcsid[] = "$Id: mbox.c,v 1.52 2004/03/18 21:51:41 nigelhorne Exp $";
148 148
 
149 149
 #if HAVE_CONFIG_H
150 150
 #include "clamav-config.h"
... ...
@@ -244,7 +247,7 @@ static	const	struct tableinit {
244 244
 	int	value;
245 245
 } rfc821headers[] = {
246 246
 	/* TODO: make these regular expressions */
247
-	{	"Content-Type",		CONTENT_TYPE		},
247
+	{	"Content-Type",			CONTENT_TYPE		},
248 248
 	{	"Content-Transfer-Encoding",	CONTENT_TRANSFER_ENCODING	},
249 249
 	{	"Content-Disposition",		CONTENT_DISPOSITION	},
250 250
 	{	NULL,				0			}
... ...
@@ -373,10 +376,13 @@ cl_mbox(const char *dir, int desc)
373 373
 		/*
374 374
 		 * It's a single message, parse the headers then the body
375 375
 		 */
376
-		do {
377
-			cli_chomp(buffer);
376
+		do
377
+			/*
378
+			 * No need to preprocess such as cli_chomp() since
379
+			 * that'll be done by parseEmailHeaders()
380
+			 */
378 381
 			messageAddLine(m, buffer);
379
-		} while(fgets(buffer, sizeof(buffer), fd) != NULL);
382
+		while(fgets(buffer, sizeof(buffer), fd) != NULL);
380 383
 
381 384
 	fclose(fd);
382 385
 
... ...
@@ -1382,9 +1388,39 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con
1382 1382
 					blobDestroy(b);
1383 1383
 				}
1384 1384
 			} else {
1385
+				bool saveIt;
1386
+
1385 1387
 				cli_dbgmsg("Not found uuencoded file\n");
1386 1388
 
1387
-				saveTextPart(mainMessage, dir);
1389
+				if(messageGetMimeType(mainMessage) == MESSAGE) {
1390
+					/*
1391
+					 * Quick peek, if the encapsulated
1392
+					 * message has no
1393
+					 * content encoding statement don't
1394
+					 * bother saving to scan, it's safe
1395
+					 *
1396
+					 * TODO: check to see if we need to
1397
+					 * find anything else, perhaps anything
1398
+					 * from the RFC821 table?
1399
+					 */
1400
+					const text *t;
1401
+
1402
+					saveIt = FALSE;
1403
+					
1404
+					for(t = messageGetBody(mainMessage); t; t = t->t_next)
1405
+						if(strncasecmp(t->t_text,
1406
+							"Content-Transfer-Encoding", 
1407
+							strlen("Content-Transfer-Encoding")) == 0) {
1408
+								saveIt = TRUE;
1409
+								break;
1410
+						}
1411
+				} else
1412
+					saveIt = TRUE;
1413
+
1414
+				if(saveIt) {
1415
+					cli_dbgmsg("Saving text part to scan\n");
1416
+					saveTextPart(mainMessage, dir);
1417
+				}
1388 1418
 			}
1389 1419
 		} else
1390 1420
 			rc = (multiparts) ? 1 : 2;	/* anything saved? */
... ...
@@ -17,6 +17,9 @@
17 17
  *
18 18
  * Change History:
19 19
  * $Log: message.c,v $
20
+ * Revision 1.40  2004/03/18 21:51:41  nigelhorne
21
+ * If a message only contains a single RFC822 message that has no encoding don't save for scanning
22
+ *
20 23
  * Revision 1.39  2004/03/18 14:05:25  nigelhorne
21 24
  * Added bounce and handle text/plain encoding messages
22 25
  *
... ...
@@ -114,7 +117,7 @@
114 114
  * uuencodebegin() no longer static
115 115
  *
116 116
  */
117
-static	char	const	rcsid[] = "$Id: message.c,v 1.39 2004/03/18 14:05:25 nigelhorne Exp $";
117
+static	char	const	rcsid[] = "$Id: message.c,v 1.40 2004/03/18 21:51:41 nigelhorne Exp $";
118 118
 
119 119
 #if HAVE_CONFIG_H
120 120
 #include "clamav-config.h"
... ...
@@ -174,7 +177,7 @@ static	const	struct	encoding_map {
174 174
 	encoding_type	type;
175 175
 } encoding_map[] = {
176 176
 	{	"7bit",			NOENCODING	},
177
-{	"text/plain",		NOENCODING	},
177
+	{	"text/plain",		NOENCODING	},
178 178
 	{	"quoted-printable",	QUOTEDPRINTABLE	},	/* rfc1522 */
179 179
 	{	"base64",		BASE64		},
180 180
 	{	"8bit",			EIGHTBIT	},
... ...
@@ -223,6 +226,7 @@ messageCreate(void)
223 223
 	message *m = (message *)cli_calloc(1, sizeof(message));
224 224
 
225 225
 	m->mimeType = NOMIME;
226
+	m->encodingType = NOENCODING;
226 227
 
227 228
 	return m;
228 229
 }