git-svn: trunk@1204

Nigel Horne authored on 2004/12/20 08:19:54
Showing 2 changed files
... ...
@@ -17,6 +17,9 @@
17 17
  *
18 18
  * Change History:
19 19
  * $Log: mbox.c,v $
20
+ * Revision 1.204  2004/12/19 23:19:54  nigelhorne
21
+ * Tidy
22
+ *
20 23
  * Revision 1.203  2004/12/19 13:50:08  nigelhorne
21 24
  * Tidy
22 25
  *
... ...
@@ -597,7 +600,7 @@
597 597
  * Compilable under SCO; removed duplicate code with message.c
598 598
  *
599 599
  */
600
-static	char	const	rcsid[] = "$Id: mbox.c,v 1.203 2004/12/19 13:50:08 nigelhorne Exp $";
600
+static	char	const	rcsid[] = "$Id: mbox.c,v 1.204 2004/12/19 23:19:54 nigelhorne Exp $";
601 601
 
602 602
 #if HAVE_CONFIG_H
603 603
 #include "clamav-config.h"
... ...
@@ -2333,7 +2336,6 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2333 2333
 
2334 2334
 				cli_dbgmsg("Mixed message with %d parts\n", multiparts);
2335 2335
 				for(i = 0; i < multiparts; i++) {
2336
-					bool addAttachment = FALSE;
2337 2336
 					bool addToText = FALSE;
2338 2337
 					const char *dtype;
2339 2338
 #ifndef	SAVE_TO_DISC
... ...
@@ -2350,7 +2352,6 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2350 2350
 
2351 2351
 					switch(messageGetMimeType(aMessage)) {
2352 2352
 					case APPLICATION:
2353
-						addAttachment = TRUE;
2354 2353
 						break;
2355 2354
 					case NOMIME:
2356 2355
 						cli_dbgmsg("No mime headers found in multipart part %d\n", i);
... ...
@@ -2400,8 +2401,8 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2400 2400
 						cli_dbgmsg("Mixed message text part disposition \"%s\"\n",
2401 2401
 							dtype);
2402 2402
 						if(strcasecmp(dtype, "attachment") == 0)
2403
-							addAttachment = TRUE;
2404
-						else if((*dtype == '\0') || (strcasecmp(dtype, "inline") == 0)) {
2403
+							break;
2404
+						if((*dtype == '\0') || (strcasecmp(dtype, "inline") == 0)) {
2405 2405
 							if(mainMessage && (mainMessage != messageIn))
2406 2406
 								messageDestroy(mainMessage);
2407 2407
 							mainMessage = NULL;
... ...
@@ -2410,7 +2411,6 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2410 2410
 							if(uuencodeBegin(aMessage)) {
2411 2411
 								cli_dbgmsg("Found uuencoded message in multipart/mixed text portion\n");
2412 2412
 								messageSetEncoding(aMessage, "x-uuencode");
2413
-								addAttachment = TRUE;
2414 2413
 							} else if((tableFind(subtypeTable, cptr) == PLAIN) &&
2415 2414
 								  (messageGetEncoding(aMessage) == NOENCODING)) {
2416 2415
 								char *filename;
... ...
@@ -2433,14 +2433,12 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2433 2433
 									cli_dbgmsg("Treating %s as attachment\n",
2434 2434
 										filename);
2435 2435
 									free(filename);
2436
-									addAttachment = TRUE;
2437 2436
 								}
2438 2437
 							} else {
2439 2438
 								if(options&CL_SCAN_MAILURL)
2440 2439
 									if(tableFind(subtypeTable, cptr) == HTML)
2441 2440
 										checkURLs(aMessage, dir);
2442 2441
 								messageAddArgument(aMessage, "filename=textportion");
2443
-								addAttachment = TRUE;
2444 2442
 							}
2445 2443
 						} else {
2446 2444
 							cli_dbgmsg("Text type %s is not supported\n", dtype);
... ...
@@ -2519,7 +2517,6 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2519 2519
 					case AUDIO:
2520 2520
 					case IMAGE:
2521 2521
 					case VIDEO:
2522
-						addAttachment = TRUE;
2523 2522
 						break;
2524 2523
 					default:
2525 2524
 						cli_warnmsg("Only text and application attachments are supported, type = %d\n",
... ...
@@ -2527,13 +2524,6 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2527 2527
 						continue;
2528 2528
 					}
2529 2529
 
2530
-					/*
2531
-					 * It must be either text or
2532
-					 * an attachment. It can't be both
2533
-					 */
2534
-					assert(addToText || addAttachment);
2535
-					assert(!(addToText && addAttachment));
2536
-
2537 2530
 					if(addToText) {
2538 2531
 						cli_dbgmsg("Adding to non mime-part\n");
2539 2532
 						aText = textAdd(aText, messageGetBody(aMessage));
... ...
@@ -2578,7 +2568,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2578 2578
 						cli_warnmsg("Unknown encryption protocol '%s' - report to bugs@clamav.net\n");
2579 2579
 					free(protocol);
2580 2580
 				} else
2581
-					cli_warnmsg("Encryption method missing protocol name - report to bugs@clamav.net\n");
2581
+					cli_dbgmsg("Encryption method missing protocol name\n");
2582 2582
 
2583 2583
 				break;
2584 2584
 			default:
... ...
@@ -2668,9 +2658,9 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2668 2668
 			return rc;
2669 2669
 
2670 2670
 		case APPLICATION:
2671
-			cptr = messageGetMimeSubtype(mainMessage);
2671
+			/*cptr = messageGetMimeSubtype(mainMessage);
2672 2672
 
2673
-			/*if((strcasecmp(cptr, "octet-stream") == 0) ||
2673
+			if((strcasecmp(cptr, "octet-stream") == 0) ||
2674 2674
 			   (strcasecmp(cptr, "x-msdownload") == 0)) {*/
2675 2675
 			{
2676 2676
 				fb = messageToFileblob(mainMessage, dir);
... ...
@@ -17,6 +17,9 @@
17 17
  *
18 18
  * Change History:
19 19
  * $Log: message.c,v $
20
+ * Revision 1.134  2004/12/19 23:19:54  nigelhorne
21
+ * Tidy
22
+ *
20 23
  * Revision 1.133  2004/12/19 13:50:08  nigelhorne
21 24
  * Tidy
22 25
  *
... ...
@@ -396,7 +399,7 @@
396 396
  * uuencodebegin() no longer static
397 397
  *
398 398
  */
399
-static	char	const	rcsid[] = "$Id: message.c,v 1.133 2004/12/19 13:50:08 nigelhorne Exp $";
399
+static	char	const	rcsid[] = "$Id: message.c,v 1.134 2004/12/19 23:19:54 nigelhorne Exp $";
400 400
 
401 401
 #if HAVE_CONFIG_H
402 402
 #include "clamav-config.h"
... ...
@@ -1057,7 +1060,7 @@ messageSetEncoding(message *m, const char *enctype)
1057 1057
 		for(e = encoding_map; e->string; e++) {
1058 1058
 			int sim;
1059 1059
 			const char lowertype = tolower(type[0]);
1060
-			
1060
+
1061 1061
 			if((lowertype != tolower(e->string[0])) && (lowertype != 'x'))
1062 1062
 				/*
1063 1063
 				 * simil is expensive, I'm yet to encounter only
... ...
@@ -1820,15 +1823,15 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
1820 1820
 			 */
1821 1821
 			datasize = (line) ? strlen(line) + 2 : 0;
1822 1822
 
1823
-			if(line && (datasize >= sizeof(smallbuf)))
1824
-				data = bigbuf = cli_malloc(datasize);
1823
+			if(datasize >= sizeof(smallbuf))
1824
+				data = bigbuf = (unsigned char *)cli_malloc(datasize);
1825 1825
 			else {
1826 1826
 				bigbuf = NULL;
1827 1827
 				data = smallbuf;
1828 1828
 				datasize = sizeof(smallbuf);
1829 1829
 			}
1830 1830
 
1831
-			uptr = decodeLine(m, enctype, line, data, datasize); 
1831
+			uptr = decodeLine(m, enctype, line, data, datasize);
1832 1832
 			if(uptr == NULL) {
1833 1833
 				if(data == bigbuf)
1834 1834
 					free(data);
... ...
@@ -2213,8 +2216,7 @@ decodeLine(message *m, encoding_type et, const char *line, unsigned char *buf, s
2213 2213
 {
2214 2214
 	size_t len;
2215 2215
 	bool softbreak;
2216
-	char *p2;
2217
-	char *copy;
2216
+	char *p2, *copy;
2218 2217
 	char base64buf[RFC2045LENGTH + 1];
2219 2218
 
2220 2219
 	/*printf("decodeLine(et = %d buflen = %u)\n", (int)et, buflen);*/
... ...
@@ -2243,7 +2245,7 @@ decodeLine(message *m, encoding_type et, const char *line, unsigned char *buf, s
2243 2243
 			}
2244 2244
 
2245 2245
 			softbreak = FALSE;
2246
-			while((line < (char *)&buf[buflen]) && *line) {
2246
+			while(buflen && *line) {
2247 2247
 				if(*line == '=') {
2248 2248
 					unsigned char byte;
2249 2249
 
... ...
@@ -2269,7 +2271,8 @@ decodeLine(message *m, encoding_type et, const char *line, unsigned char *buf, s
2269 2269
 					*buf++ = byte;
2270 2270
 				} else
2271 2271
 					*buf++ = *line;
2272
-				line++;
2272
+				++line;
2273
+				--buflen;
2273 2274
 			}
2274 2275
 			if(!softbreak)
2275 2276
 				/* Put the new line back in */