git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@616 77e5149b-7576-45b1-b177-96237e5ba77b
Nigel Horne authored on 2004/06/18 19:09:33... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Fri Jun 18 11:08:26 BST 2004 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav: Allow any number of alternatives in |
|
4 |
+ multipart messages |
|
5 |
+ |
|
1 | 6 |
Wed Jun 16 09:09:45 BST 2004 (njh) |
2 | 7 |
---------------------------------- |
3 | 8 |
* clamav-milter: Added access to sendmail variables in template |
... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: mbox.c,v $ |
20 |
+ * Revision 1.77 2004/06/18 10:07:12 nigelhorne |
|
21 |
+ * Allow any number of alternatives in multipart messages |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.76 2004/06/16 08:07:39 nigelhorne |
21 | 24 |
* Added thread safety |
22 | 25 |
* |
... | ... |
@@ -216,7 +219,7 @@ |
216 | 216 |
* Compilable under SCO; removed duplicate code with message.c |
217 | 217 |
* |
218 | 218 |
*/ |
219 |
-static char const rcsid[] = "$Id: mbox.c,v 1.76 2004/06/16 08:07:39 nigelhorne Exp $"; |
|
219 |
+static char const rcsid[] = "$Id: mbox.c,v 1.77 2004/06/18 10:07:12 nigelhorne Exp $"; |
|
220 | 220 |
|
221 | 221 |
#if HAVE_CONFIG_H |
222 | 222 |
#include "clamav-config.h" |
... | ... |
@@ -651,7 +654,7 @@ parseEmailHeader(message *m, const char *line, const table_t *rfc821Table) |
651 | 651 |
static int /* success or fail */ |
652 | 652 |
parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, const char *dir, table_t *rfc821Table, table_t *subtypeTable) |
653 | 653 |
{ |
654 |
- message *messages[MAXALTERNATIVE]; |
|
654 |
+ message **messages; /* parts of a multipart message */ |
|
655 | 655 |
int inhead, inMimeHead, i, rc = 1, htmltextPart, multiparts = 0; |
656 | 656 |
text *aText; |
657 | 657 |
blob *blobList[MAX_ATTACHMENTS], **blobs; |
... | ... |
@@ -668,6 +671,7 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con |
668 | 668 |
|
669 | 669 |
aText = textIn; |
670 | 670 |
blobs = blobsIn; |
671 |
+ messages = NULL; |
|
671 | 672 |
mainMessage = messageIn; |
672 | 673 |
|
673 | 674 |
/* Anything left to be parsed? */ |
... | ... |
@@ -767,9 +771,11 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con |
767 | 767 |
* This looks like parseEmailHeaders() - maybe there's |
768 | 768 |
* some duplication of code to be cleaned up |
769 | 769 |
*/ |
770 |
- for(multiparts = 0; t_line && (multiparts < MAXALTERNATIVE); multiparts++) { |
|
770 |
+ for(multiparts = 0; t_line; multiparts++) { |
|
771 | 771 |
int lines = 0; |
772 | 772 |
|
773 |
+ messages = cli_realloc(messages, ((multiparts + 1) * sizeof(message *))); |
|
774 |
+ |
|
773 | 775 |
aMessage = messages[multiparts] = messageCreate(); |
774 | 776 |
|
775 | 777 |
cli_dbgmsg("Now read in part %d\n", multiparts); |
... | ... |
@@ -903,8 +909,11 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con |
903 | 903 |
mainMessage = NULL; |
904 | 904 |
} |
905 | 905 |
|
906 |
- if(multiparts == 0) |
|
906 |
+ if(multiparts == 0) { |
|
907 |
+ if(messages) |
|
908 |
+ free(messages); |
|
907 | 909 |
return 2; /* Nothing to do */ |
910 |
+ } |
|
908 | 911 |
|
909 | 912 |
cli_dbgmsg("The message has %d parts\n", multiparts); |
910 | 913 |
cli_dbgmsg("Find out the multipart type(%s)\n", mimeSubtype); |
... | ... |
@@ -1358,6 +1367,9 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con |
1358 | 1358 |
if(aText && (textIn == NULL)) |
1359 | 1359 |
textDestroy(aText); |
1360 | 1360 |
|
1361 |
+ if(messages) |
|
1362 |
+ free(messages); |
|
1363 |
+ |
|
1361 | 1364 |
return rc; |
1362 | 1365 |
|
1363 | 1366 |
case MESSAGE: |
... | ... |
@@ -1404,6 +1416,8 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con |
1404 | 1404 |
|
1405 | 1405 |
if(mainMessage && (mainMessage != messageIn)) |
1406 | 1406 |
messageDestroy(mainMessage); |
1407 |
+ if(messages) |
|
1408 |
+ free(messages); |
|
1407 | 1409 |
return 0; |
1408 | 1410 |
|
1409 | 1411 |
case APPLICATION: |
... | ... |
@@ -1598,6 +1612,9 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con |
1598 | 1598 |
if(mainMessage && (mainMessage != messageIn)) |
1599 | 1599 |
messageDestroy(mainMessage); |
1600 | 1600 |
|
1601 |
+ if(messages) |
|
1602 |
+ free(messages); |
|
1603 |
+ |
|
1601 | 1604 |
cli_dbgmsg("parseEmailBody() returning %d\n", rc); |
1602 | 1605 |
|
1603 | 1606 |
return rc; |
... | ... |
@@ -25,8 +25,6 @@ typedef enum { |
25 | 25 |
NOENCODING, QUOTEDPRINTABLE, BASE64, EIGHTBIT, BINARY, UUENCODE, EEXTENSION |
26 | 26 |
} encoding_type; |
27 | 27 |
|
28 |
-#define MAXALTERNATIVE 5 /* The maximum number of alternatives allowed in a message */ |
|
29 |
- |
|
30 | 28 |
/* tk: shut up manager.c warning */ |
31 | 29 |
#include <clamav.h> |
32 | 30 |
|