Browse code

Scan early if possible

git-svn: trunk@1948

Nigel Horne authored on 2006/05/04 00:41:44
Showing 6 changed files
... ...
@@ -16,7 +16,7 @@
16 16
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 17
  *  MA 02110-1301, USA.
18 18
  */
19
-static	char	const	rcsid[] = "$Id: blob.c,v 1.45 2006/05/03 09:36:40 nigelhorne Exp $";
19
+static	char	const	rcsid[] = "$Id: blob.c,v 1.46 2006/05/03 15:41:44 nigelhorne Exp $";
20 20
 
21 21
 #if HAVE_CONFIG_H
22 22
 #include "clamav-config.h"
... ...
@@ -461,20 +461,17 @@ fileblobAddData(fileblob *fb, const unsigned char *data, size_t len)
461 461
 	assert(data != NULL);
462 462
 
463 463
 	if(fb->fp) {
464
-#if	0
465
-		extern cli_ctx *current_ctx;
466
-
467
-		if(current_ctx) {
468
-			if(current_ctx->scanned)
469
-			    *current_ctx->scanned += len / CL_COUNT_PRECISION;
470
-
471
-			if(cli_scanbuff((char *) data, len, current_ctx->virname, current_ctx->engine, 0) == CL_VIRUS) {
472
-				cli_dbgmsg("found %s\n", *current_ctx->virname);
473
-			    /*ret = CL_VIRUS;
474
-			    break;*/
464
+		if(fb->isInfected)	/* pretend all was written */
465
+			return 0;
466
+		if(fb->ctx) {
467
+			if(fb->ctx->scanned)
468
+				*fb->ctx->scanned += len / CL_COUNT_PRECISION;
469
+
470
+			if((len > 5) && (cli_scanbuff((char *)data, len, fb->ctx->virname, fb->ctx->engine, 0) == CL_VIRUS)) {
471
+				cli_dbgmsg("found %s\n", *fb->ctx->virname);
472
+				fb->isInfected = 1;
475 473
 			}
476 474
 		}
477
-#endif
478 475
 
479 476
 		if(fwrite(data, len, 1, fb->fp) != 1) {
480 477
 			cli_errmsg("fileblobAddData: Can't write %u bytes to temporary file %s: %s\n", len, fb->b.name, strerror(errno));
... ...
@@ -492,6 +489,18 @@ fileblobGetFilename(const fileblob *fb)
492 492
 	return blobGetFilename(&(fb->b));
493 493
 }
494 494
 
495
+void
496
+fileblobSetCTX(fileblob *fb, cli_ctx *ctx)
497
+{
498
+	fb->ctx = ctx;
499
+}
500
+
501
+int
502
+fileblobContainsVirus(const fileblob *fb)
503
+{
504
+	return fb->isInfected ? TRUE : FALSE;
505
+}
506
+
495 507
 /*
496 508
  * Different operating systems allow different characters in their filenames
497 509
  * FIXME: What does QNX want? There is no #ifdef C_QNX, but if there were
... ...
@@ -52,14 +52,18 @@ void	blobGrow(blob *b, size_t len);
52 52
 typedef	struct fileblob {
53 53
 	FILE	*fp;
54 54
 	blob	b;
55
-	int	isNotEmpty;
55
+	int	isNotEmpty : 1;
56
+	int	isInfected : 1;
57
+	cli_ctx	*ctx;
56 58
 } fileblob;
57 59
 
58 60
 fileblob	*fileblobCreate(void);
59 61
 void	fileblobDestroy(fileblob *fb);
60 62
 void	fileblobSetFilename(fileblob *fb, const char *dir, const char *filename);
61 63
 const	char	*fileblobGetFilename(const fileblob *fb);
64
+void	fileblobSetCTX(fileblob *fb, cli_ctx *ctx);
62 65
 int	fileblobAddData(fileblob *fb, const unsigned char *data, size_t len);
66
+int	fileblobContainsVirus(const fileblob *fb);
63 67
 void	sanitiseName(char *name);
64 68
 
65 69
 /* Maximum filenames under various systems */
... ...
@@ -16,7 +16,7 @@
16 16
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 17
  *  MA 02110-1301, USA.
18 18
  */
19
-static	char	const	rcsid[] = "$Id: mbox.c,v 1.294 2006/05/03 09:36:40 nigelhorne Exp $";
19
+static	char	const	rcsid[] = "$Id: mbox.c,v 1.295 2006/05/03 15:41:44 nigelhorne Exp $";
20 20
 
21 21
 #if HAVE_CONFIG_H
22 22
 #include "clamav-config.h"
... ...
@@ -196,7 +196,7 @@ static	int	rfc1341(message *m, const char *dir);
196 196
 #endif
197 197
 static	bool	usefulHeader(int commandNumber, const char *cmd);
198 198
 static	char	*getline_from_mbox(char *buffer, size_t len, FILE *fin);
199
-static	bool	mailStart(const char *line);
199
+static	bool	isBounceStart(const char *line);
200 200
 
201 201
 static	void	checkURLs(message *m, const char *dir);
202 202
 #ifdef	WITH_CURL
... ...
@@ -673,6 +673,9 @@ cli_mbox(const char *dir, int desc, cli_ctx *ctx)
673 673
 				}
674 674
 				messageSetEncoding(m, "base64");
675 675
 
676
+				messageSetCTX(m, ctx);
677
+				fileblobSetCTX(fb, ctx);
678
+
676 679
 				lastline = 0;
677 680
 				do {
678 681
 					int length = 0, datalen;
... ...
@@ -809,6 +812,7 @@ cli_mbox(const char *dir, int desc, cli_ctx *ctx)
809 809
 					return CL_EMEM;
810 810
 				}
811 811
 				messageSetEncoding(m, "quoted-printable");
812
+				messageSetCTX(m, ctx);
812 813
 
813 814
 				line = NULL;
814 815
 
... ...
@@ -1074,6 +1078,7 @@ cli_parse_mbox(const char *dir, int desc, cli_ctx *ctx)
1074 1074
 	segv = signal(SIGSEGV, sigsegv);
1075 1075
 #endif
1076 1076
 
1077
+	retcode = CL_SUCCESS;
1077 1078
 	/*
1078 1079
 	 * Is it a UNIX style mbox with more than one
1079 1080
 	 * mail message, or just a single mail message?
... ...
@@ -1120,6 +1125,7 @@ cli_parse_mbox(const char *dir, int desc, cli_ctx *ctx)
1120 1120
 
1121 1121
 		lastLineWasEmpty = FALSE;
1122 1122
 		messagenumber = 1;
1123
+		messageSetCTX(m, ctx);
1123 1124
 
1124 1125
 		do {
1125 1126
 			cli_chomp(buffer);
... ...
@@ -1133,13 +1139,22 @@ cli_parse_mbox(const char *dir, int desc, cli_ctx *ctx)
1133 1133
 					messageReset(m);
1134 1134
 					continue;
1135 1135
 				}
1136
+				messageSetCTX(body, ctx);
1136 1137
 				messageDestroy(m);
1137
-				if(messageGetBody(body))
1138
-					if(!parseEmailBody(body, NULL, dir, rfc821, subtype, ctx)) {
1138
+				if(messageGetBody(body)) {
1139
+					int rc = parseEmailBody(body, NULL, dir, rfc821, subtype, ctx);
1140
+					if(rc == 0) {
1139 1141
 						messageReset(body);
1140 1142
 						m = body;
1141 1143
 						continue;
1144
+					} else if(rc == 3) {
1145
+						cli_dbgmsg("Message number %d is infected\n",
1146
+							messagenumber);
1147
+						retcode = CL_VIRUS;
1148
+						m = body = NULL;
1149
+						break;
1142 1150
 					}
1151
+				}
1143 1152
 				/*
1144 1153
 				 * Starting a new message, throw away all the
1145 1154
 				 * information about the old one. It would
... ...
@@ -1150,6 +1165,7 @@ cli_parse_mbox(const char *dir, int desc, cli_ctx *ctx)
1150 1150
 				 */
1151 1151
 				m = body;
1152 1152
 				messageReset(body);
1153
+				messageSetCTX(body, ctx);
1153 1154
 
1154 1155
 				cli_dbgmsg("Finished processing message\n");
1155 1156
 			} else
... ...
@@ -1170,9 +1186,12 @@ cli_parse_mbox(const char *dir, int desc, cli_ctx *ctx)
1170 1170
 
1171 1171
 		fclose(fd);
1172 1172
 
1173
-		cli_dbgmsg("Extract attachments from email %d\n", messagenumber);
1174
-		body = parseEmailHeaders(m, rfc821);
1175
-		messageDestroy(m);
1173
+		if(retcode == CL_SUCCESS) {
1174
+			cli_dbgmsg("Extract attachments from email %d\n", messagenumber);
1175
+			body = parseEmailHeaders(m, rfc821);
1176
+		}
1177
+		if(m)
1178
+			messageDestroy(m);
1176 1179
 	} else {
1177 1180
 		/*
1178 1181
 		 * It's a single message, parse the headers then the body
... ...
@@ -1198,15 +1217,21 @@ cli_parse_mbox(const char *dir, int desc, cli_ctx *ctx)
1198 1198
 		fclose(fd);
1199 1199
 	}
1200 1200
 
1201
-	retcode = CL_SUCCESS;
1202
-
1203 1201
 	if(body) {
1204 1202
 		/*
1205 1203
 		 * Write out the last entry in the mailbox
1206 1204
 		 */
1207
-		if(messageGetBody(body))
1208
-			if(!parseEmailBody(body, NULL, dir, rfc821, subtype, ctx))
1209
-				retcode = CL_EFORMAT;
1205
+		if((retcode == CL_SUCCESS) && messageGetBody(body)) {
1206
+			messageSetCTX(body, ctx);
1207
+			switch(parseEmailBody(body, NULL, dir, rfc821, subtype, ctx)) {
1208
+				case 0:
1209
+					retcode = CL_EFORMAT;
1210
+					break;
1211
+				case 3:
1212
+					retcode = CL_VIRUS;
1213
+					break;
1214
+			}
1215
+		}
1210 1216
 
1211 1217
 		/*
1212 1218
 		 * Tidy up and quit
... ...
@@ -1720,6 +1745,7 @@ parseEmailHeader(message *m, const char *line, const table_t *rfc821)
1720 1720
  *	0 for fail
1721 1721
  *	1 for success, attachments saved
1722 1722
  *	2 for success, attachments not saved
1723
+ *	3 for virus found
1723 1724
  */
1724 1725
 static int	/* success or fail */
1725 1726
 parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t *rfc821Table, const table_t *subtypeTable, cli_ctx *ctx)
... ...
@@ -1730,6 +1756,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
1730 1730
 	const char *cptr;
1731 1731
 	message *mainMessage;
1732 1732
 	fileblob *fb;
1733
+	bool infected = FALSE;
1733 1734
 
1734 1735
 	cli_dbgmsg("in parseEmailBody\n");
1735 1736
 
... ...
@@ -1899,6 +1926,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
1899 1899
 					multiparts--;
1900 1900
 					continue;
1901 1901
 				}
1902
+				messageSetCTX(aMessage, ctx);
1902 1903
 
1903 1904
 				cli_dbgmsg("Now read in part %d\n", multiparts);
1904 1905
 
... ...
@@ -2327,8 +2355,13 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2327 2327
 								messageSetEncoding(mainMessage, "x-bunhex");
2328 2328
 								fb = messageToFileblob(mainMessage, dir);
2329 2329
 
2330
-								if(fb)
2330
+								if(fb) {
2331
+									if(fileblobContainsVirus(fb)) {
2332
+										infected = TRUE;
2333
+										rc = 3;
2334
+									}
2331 2335
 									fileblobDestroy(fb);
2336
+								}
2332 2337
 							}
2333 2338
 							if(mainMessage != messageIn)
2334 2339
 								messageDestroy(mainMessage);
... ...
@@ -2339,8 +2372,13 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2339 2339
 								messageSetEncoding(aMessage, "x-binhex");
2340 2340
 								fb = messageToFileblob(aMessage, dir);
2341 2341
 
2342
-								if(fb)
2342
+								if(fb) {
2343
+									if(fileblobContainsVirus(fb)) {
2344
+										infected = TRUE;
2345
+										rc = 3;
2346
+									}
2343 2347
 									fileblobDestroy(fb);
2348
+								}
2344 2349
 								assert(aMessage == messages[i]);
2345 2350
 								messageReset(messages[i]);
2346 2351
 							}
... ...
@@ -2455,9 +2493,16 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2455 2455
 						messageDestroy(messages[i]);
2456 2456
 						messages[i] = NULL;
2457 2457
 						if(body) {
2458
+							messageSetCTX(body, ctx);
2458 2459
 							rc = parseEmailBody(body, NULL, dir, rfc821Table, subtypeTable, ctx);
2460
+							if(messageContainsVirus(body))
2461
+								infected = TRUE;
2459 2462
 							messageDestroy(body);
2460 2463
 						}
2464
+						if(infected) {
2465
+							rc = 3;
2466
+							break;
2467
+						}
2461 2468
 #endif
2462 2469
 						continue;
2463 2470
 					case MULTIPART:
... ...
@@ -2496,12 +2541,21 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2496 2496
 					} else {
2497 2497
 						fb = messageToFileblob(aMessage, dir);
2498 2498
 
2499
-						if(fb)
2499
+						if(fb) {
2500
+							if(fileblobContainsVirus(fb))
2501
+								infected = TRUE;
2500 2502
 							fileblobDestroy(fb);
2503
+						}
2501 2504
 					}
2502 2505
 					assert(aMessage == messages[i]);
2503
-					messageDestroy(messages[i]);
2506
+					if(messageContainsVirus(aMessage))
2507
+						infected = TRUE;
2508
+					messageDestroy(aMessage);
2504 2509
 					messages[i] = NULL;
2510
+					if(infected) {
2511
+						rc = 3;
2512
+						break;
2513
+					}
2505 2514
 				}
2506 2515
 
2507 2516
 				/* rc = parseEmailBody(NULL, NULL, dir, rfc821Table, subtypeTable, ctx); */
... ...
@@ -2545,10 +2599,11 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2545 2545
 				messageDestroy(mainMessage);
2546 2546
 
2547 2547
 			if(aText && (textIn == NULL)) {
2548
-				if((fb = fileblobCreate()) != NULL) {
2548
+				if((!infected) && (fb = fileblobCreate()) != NULL) {
2549 2549
 					cli_dbgmsg("Save non mime and/or text/plain part\n");
2550 2550
 					fileblobSetFilename(fb, dir, "textpart");
2551 2551
 					/*fileblobAddData(fb, "Received: by clamd (textpart)\n", 30);*/
2552
+					fileblobSetCTX(fb, ctx);
2552 2553
 					(void)textToFileblob(aText, fb);
2553 2554
 
2554 2555
 					fileblobDestroy(fb);
... ...
@@ -2585,6 +2640,8 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2585 2585
 				if(m) {
2586 2586
 					cli_dbgmsg("Decode rfc822");
2587 2587
 
2588
+					messageSetCTX(m, ctx);
2589
+
2588 2590
 					if(mainMessage && (mainMessage != messageIn)) {
2589 2591
 						messageDestroy(mainMessage);
2590 2592
 						mainMessage = NULL;
... ...
@@ -2667,7 +2724,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2667 2667
 			if(l == NULL)
2668 2668
 				continue;
2669 2669
 
2670
-			if(!mailStart(lineGetData(l)))
2670
+			if(!isBounceStart(lineGetData(l)))
2671 2671
 				continue;
2672 2672
 
2673 2673
 			/*
... ...
@@ -2733,6 +2790,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2733 2733
 				break;
2734 2734
 			cli_dbgmsg("Save non mime part bounce message\n");
2735 2735
 			fileblobSetFilename(fb, dir, "bounce");
2736
+			fileblobSetCTX(fb, ctx);
2736 2737
 			fileblobAddData(fb, (unsigned char *)"Received: by clamd (bounce)\n", 28);
2737 2738
 
2738 2739
 			inheader = TRUE;
... ...
@@ -2757,7 +2815,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2757 2757
 				l = t->t_line;
2758 2758
 				if((!inheader) && l) {
2759 2759
 					s = lineGetData(l);
2760
-					if(mailStart(s)) {
2760
+					if(isBounceStart(s)) {
2761 2761
 						cli_dbgmsg("Found the start of another bounce candidate (%s)\n", s);
2762 2762
 						break;
2763 2763
 					}
... ...
@@ -2853,6 +2911,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2853 2853
 			if(t && ((fb = fileblobCreate()) != NULL)) {
2854 2854
 				cli_dbgmsg("Found a bounce message\n");
2855 2855
 				fileblobSetFilename(fb, dir, "bounce");
2856
+				fileblobSetCTX(fb, ctx);
2856 2857
 				if(textToFileblob(start, fb) == NULL)
2857 2858
 					cli_dbgmsg("Nothing new to save in the bounce message");
2858 2859
 				else
... ...
@@ -2883,6 +2942,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2883 2883
 					cli_dbgmsg("Found a bounce message with no header at '%s'\n",
2884 2884
 						lineGetData(t_line->t_line));
2885 2885
 					fileblobSetFilename(fb, dir, "bounce");
2886
+					fileblobSetCTX(fb, ctx);
2886 2887
 					fileblobAddData(fb,
2887 2888
 						(const unsigned char *)"Received: by clamd (bounce)\n",
2888 2889
 						28);
... ...
@@ -2925,6 +2985,9 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2925 2925
 	if(messages)
2926 2926
 		free(messages);
2927 2927
 
2928
+	if((rc == CL_SUCCESS) && infected)
2929
+		rc = CL_VIRUS;
2930
+
2928 2931
 	cli_dbgmsg("parseEmailBody() returning %d\n", rc);
2929 2932
 
2930 2933
 	return rc;
... ...
@@ -4221,8 +4284,11 @@ getline_from_mbox(char *buffer, size_t len, FILE *fin)
4221 4221
 	return ret;
4222 4222
 }
4223 4223
 
4224
+/*
4225
+ * Is this line a candidate for the start of a bounce message?
4226
+ */
4224 4227
 static bool
4225
-mailStart(const char *line)
4228
+isBounceStart(const char *line)
4226 4229
 {
4227 4230
 	if(line == NULL)
4228 4231
 		return FALSE;
... ...
@@ -16,7 +16,7 @@
16 16
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 17
  *  MA 02110-1301, USA.
18 18
  */
19
-static	char	const	rcsid[] = "$Id: message.c,v 1.166 2006/05/03 09:36:40 nigelhorne Exp $";
19
+static	char	const	rcsid[] = "$Id: message.c,v 1.167 2006/05/03 15:41:44 nigelhorne Exp $";
20 20
 
21 21
 #if HAVE_CONFIG_H
22 22
 #include "clamav-config.h"
... ...
@@ -83,7 +83,7 @@ static	const	char	*messageGetArgument(const message *m, int arg);
83 83
 /*
84 84
  * http://oopweb.com/CPP/Documents/FunctionPointers/Volume/CCPP/callback/callback.html
85 85
  */
86
-static	void	*messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy)(void *), void (*setFilename)(void *, const char *, const char *), void (*addData)(void *, const unsigned char *, size_t), void *(*exportText)(const text *, void *));
86
+static	void	*messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy)(void *), void (*setFilename)(void *, const char *, const char *), void (*addData)(void *, const unsigned char *, size_t), void *(*exportText)(const text *, void *), void (*setCTX)(void *, cli_ctx *));
87 87
 static	int	usefulArg(const char *arg);
88 88
 static	void	messageDedup(message *m);
89 89
 static	char	*rfc2231(const char *in);
... ...
@@ -1008,7 +1008,7 @@ messageClean(message *m)
1008 1008
  * last item that was exported. That's sufficient for now.
1009 1009
  */
1010 1010
 static void *
1011
-messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy)(void *), void (*setFilename)(void *, const char *, const char *), void (*addData)(void *, const unsigned char *, size_t), void *(*exportText)(const text *, void *))
1011
+messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy)(void *), void (*setFilename)(void *, const char *, const char *), void (*addData)(void *, const unsigned char *, size_t), void *(*exportText)(const text *, void *), void(*setCTX)(void *, cli_ctx *))
1012 1012
 {
1013 1013
 	void *ret;
1014 1014
 	const text *t_line;
... ...
@@ -1027,6 +1027,9 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
1027 1027
 
1028 1028
 	cli_dbgmsg("messageExport: numberOfEncTypes == %d\n", m->numberOfEncTypes);
1029 1029
 
1030
+	if(setCTX && m->ctx)
1031
+		(*setCTX)(ret, m->ctx);
1032
+
1030 1033
 	if((t_line = binhexBegin(m)) != NULL) {
1031 1034
 		unsigned char byte;
1032 1035
 		unsigned long newlen = 0L, len, l;
... ...
@@ -1514,7 +1517,7 @@ fileblob *
1514 1514
 messageToFileblob(message *m, const char *dir)
1515 1515
 {
1516 1516
 	cli_dbgmsg("messageToFileblob\n");
1517
-	return messageExport(m, dir, (void *)fileblobCreate, (void *)fileblobDestroy, (void *)fileblobSetFilename, (void *)fileblobAddData, (void *)textToFileblob);
1517
+	return messageExport(m, dir, (void *)fileblobCreate, (void *)fileblobDestroy, (void *)fileblobSetFilename, (void *)fileblobAddData, (void *)textToFileblob, (void *)fileblobSetCTX);
1518 1518
 }
1519 1519
 
1520 1520
 /*
... ...
@@ -1524,7 +1527,7 @@ messageToFileblob(message *m, const char *dir)
1524 1524
 blob *
1525 1525
 messageToBlob(message *m)
1526 1526
 {
1527
-	return messageExport(m, NULL, (void *)blobCreate, (void *)blobDestroy, (void *)blobSetFilename, (void *)blobAddData, (void *)textToBlob);
1527
+	return messageExport(m, NULL, (void *)blobCreate, (void *)blobDestroy, (void *)blobSetFilename, (void *)blobAddData, (void *)textToBlob, NULL);
1528 1528
 }
1529 1529
 
1530 1530
 /*
... ...
@@ -2207,6 +2210,18 @@ usefulArg(const char *arg)
2207 2207
 	return 1;
2208 2208
 }
2209 2209
 
2210
+void
2211
+messageSetCTX(message *m, cli_ctx *ctx)
2212
+{
2213
+	m->ctx = ctx;
2214
+}
2215
+
2216
+int
2217
+messageContainsVirus(const message *m)
2218
+{
2219
+	return m->isInfected ? TRUE : FALSE;
2220
+}
2221
+
2210 2222
 /*
2211 2223
  * We've run out of memory. Try to recover some by
2212 2224
  * deduping the message
... ...
@@ -29,9 +29,12 @@ typedef struct message {
29 29
 	char	**mimeArguments;
30 30
 	char	*mimeDispositionType;	/* probably attachment */
31 31
 	text	*body_first, *body_last;
32
+	cli_ctx	*ctx;
32 33
 
33 34
 	char	base64_1, base64_2, base64_3;
34 35
 	int	base64chars;
36
+	int	isInfected : 1;
37
+
35 38
 	/*
36 39
 	 * Markers for the start of various non MIME messages that could
37 40
 	 * be included within this message
... ...
@@ -73,5 +76,7 @@ const	text	*encodingLine(const message *m);
73 73
 void	messageClearMarkers(message *m);
74 74
 unsigned char	*decodeLine(message *m, encoding_type enctype, const char *line, unsigned char *buf, size_t buflen);
75 75
 int	isuuencodebegin(const char *line);
76
+void	messageSetCTX(message *m, cli_ctx *ctx);
77
+int	messageContainsVirus(const message *m);
76 78
 
77 79
 #endif	/*_MESSAGE_H*/
... ...
@@ -35,7 +35,7 @@
35 35
  *	cli_mbox decode it
36 36
  * TODO: Remove the vcard handling
37 37
  */
38
-static	char	const	rcsid[] = "$Id: pst.c,v 1.17 2006/05/02 15:20:12 nigelhorne Exp $";
38
+static	char	const	rcsid[] = "$Id: pst.c,v 1.18 2006/05/03 15:41:43 nigelhorne Exp $";
39 39
 
40 40
 #if HAVE_CONFIG_H
41 41
 #include "clamav-config.h"	/* must come first */
... ...
@@ -55,6 +55,8 @@ static	char	const	rcsid[] = "$Id: pst.c,v 1.17 2006/05/02 15:20:12 nigelhorne Ex
55 55
 
56 56
 #include "pst.h"
57 57
 
58
+#include "blob.h"
59
+
58 60
 #define	DWORD	unsigned int
59 61
 
60 62
 #define DEBUG_VERSION 1
... ...
@@ -453,9 +455,9 @@ static	char	*my_stristr(const char *haystack, const char *needle);
453 453
 int
454 454
 cli_pst(const char *dir, int desc)
455 455
 {
456
-	cli_warnmsg("PST files not yet supported\n");
457
-	return CL_EFORMAT;
458
-	/*return pst_decode(dir, desc);*/
456
+	/*cli_warnmsg("PST files not yet supported\n");
457
+	return CL_EFORMAT;*/
458
+	return pst_decode(dir, desc);
459 459
 }
460 460
 
461 461
 static const char *
... ...
@@ -4609,16 +4611,21 @@ struct file_ll {
4609 4609
 #define C_TIME_SIZE 500
4610 4610
 
4611 4611
 // char *check_filename(char *fname) {{{1
4612
-char *check_filename(char *fname) {
4613
-  char *t = fname;
4614
-  if (t == NULL) {
4615
-    return fname;
4616
-  }
4612
+static char *
4613
+check_filename(char *fname)
4614
+{
4615
+	/*char *t = fname;*/
4616
+	if(fname == NULL)
4617
+		return fname;
4618
+
4619
+#if	0
4617 4620
   while ((t = strpbrk(t, "/\\:")) != NULL) {
4618 4621
     // while there are characters in the second string that we don't want
4619 4622
     *t = '_'; //replace them with an underscore
4620 4623
   }
4621
-  return fname;
4624
+#endif
4625
+	sanitiseName(fname);
4626
+	return fname;
4622 4627
 }
4623 4628
 
4624 4629
 static int