git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@285 77e5149b-7576-45b1-b177-96237e5ba77b
Nigel Horne authored on 2004/02/15 04:05:27... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: mbox.c,v $ |
20 |
+ * Revision 1.43 2004/02/14 19:04:05 nigelhorne |
|
21 |
+ * Handle spaces in boundaries |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.42 2004/02/14 17:23:45 nigelhorne |
21 | 24 |
* Had deleted O_BINARY by mistake |
22 | 25 |
* |
... | ... |
@@ -117,7 +120,7 @@ |
117 | 117 |
* Compilable under SCO; removed duplicate code with message.c |
118 | 118 |
* |
119 | 119 |
*/ |
120 |
-static char const rcsid[] = "$Id: mbox.c,v 1.42 2004/02/14 17:23:45 nigelhorne Exp $"; |
|
120 |
+static char const rcsid[] = "$Id: mbox.c,v 1.43 2004/02/14 19:04:05 nigelhorne Exp $"; |
|
121 | 121 |
|
122 | 122 |
#if HAVE_CONFIG_H |
123 | 123 |
#include "clamav-config.h" |
... | ... |
@@ -464,6 +467,8 @@ parseEmailHeader(message *m, const char *line, const table_t *rfc821Table) |
464 | 464 |
char *strptr; |
465 | 465 |
#endif |
466 | 466 |
|
467 |
+ cli_dbgmsg("parseEmailHeader '%s'\n", line); |
|
468 |
+ |
|
467 | 469 |
cmd = strtok_r(copy, " \t", &strptr); |
468 | 470 |
|
469 | 471 |
if(*cmd) { |
... | ... |
@@ -595,12 +600,22 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con |
595 | 595 |
/* |
596 | 596 |
* Get to the start of the first message |
597 | 597 |
*/ |
598 |
- for(t_line = messageGetBody(mainMessage); t_line; t_line = t_line->t_next) |
|
598 |
+ t_line = messageGetBody(mainMessage); |
|
599 |
+ |
|
600 |
+ if(t_line == NULL) { |
|
601 |
+ cli_warnmsg("Multipart MIME message has no body\n"); |
|
602 |
+ free((char *)boundary); |
|
603 |
+ mimeType = NOMIME; |
|
604 |
+ break; |
|
605 |
+ } |
|
606 |
+ |
|
607 |
+ do |
|
599 | 608 |
if(boundaryStart(t_line->t_text, boundary)) |
600 | 609 |
break; |
610 |
+ while((t_line = t_line->t_next) != NULL); |
|
601 | 611 |
|
602 | 612 |
if(t_line == NULL) { |
603 |
- cli_warnmsg("Multipart MIME message contains no parts\n"); |
|
613 |
+ cli_warnmsg("Multipart MIME message contains no boundary lines\n"); |
|
604 | 614 |
/* |
605 | 615 |
* Free added by Thomas Lamy |
606 | 616 |
* <Thomas.Lamy@in-online.net> |
... | ... |
@@ -1332,6 +1347,7 @@ boundaryStart(const char *line, const char *boundary) |
1332 | 1332 |
* ------ =_NextPart_000_01C31177.9DC7C000 |
1333 | 1333 |
* notice the extra '-' |
1334 | 1334 |
*/ |
1335 |
+ /*cli_dbgmsg("boundaryStart: line = '%s' boundary = '%s'\n", line, boundary);*/ |
|
1335 | 1336 |
if(strstr(line, boundary) != NULL) { |
1336 | 1337 |
cli_dbgmsg("found %s in %s\n", boundary, line); |
1337 | 1338 |
return 1; |
... | ... |
@@ -1569,10 +1585,14 @@ parseMimeHeader(message *m, const char *cmd, const table_t *rfc821Table, const c |
1569 | 1569 |
} |
1570 | 1570 |
|
1571 | 1571 |
/* |
1572 |
- * Add in all the arguments. |
|
1572 |
+ * Add in all rest of the the arguments. |
|
1573 |
+ * e.g. if the header is this: |
|
1574 |
+ * Content-Type:', arg='multipart/mixed; boundary=foo |
|
1575 |
+ * we find the boundary argument set it |
|
1573 | 1576 |
*/ |
1574 |
- while((copy = strtok_r(NULL, "\r\n \t", &strptr))) |
|
1575 |
- messageAddArgument(m, copy); |
|
1577 |
+ copy = strtok_r(NULL, "", &strptr); |
|
1578 |
+ if(copy) |
|
1579 |
+ messageAddArguments(m, copy); |
|
1576 | 1580 |
} |
1577 | 1581 |
break; |
1578 | 1582 |
case CONTENT_TRANSFER_ENCODING: |