git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@878 77e5149b-7576-45b1-b177-96237e5ba77b
Nigel Horne authored on 2004/09/16 20:22:03... | ... |
@@ -1,6 +1,11 @@ |
1 |
+Thu Sep 16 12:20:59 BST 2004 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * libvclamav/mbox.c: Improved handling of line breaks in the middle of |
|
4 |
+ headers for multipart sections |
|
5 |
+ |
|
1 | 6 |
Thu Sep 16 11:07:37 BST 2004 (njh) |
2 | 7 |
---------------------------------- |
3 |
- * libclamav/mbox:c If a false or invented encoding type is stated attempt |
|
8 |
+ * libclamav/mbox.c: If a false or invented encoding type is stated attempt |
|
4 | 9 |
to decode with all known decoders |
5 | 10 |
|
6 | 11 |
Thu Sep 16 09:58:01 BST 2004 (njh) |
... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: mbox.c,v $ |
20 |
+ * Revision 1.124 2004/09/16 11:20:33 nigelhorne |
|
21 |
+ * Better handling of folded headers in multipart messages |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.123 2004/09/16 08:56:19 nigelhorne |
21 | 24 |
* Handle RFC822 Comments |
22 | 25 |
* |
... | ... |
@@ -357,7 +360,7 @@ |
357 | 357 |
* Compilable under SCO; removed duplicate code with message.c |
358 | 358 |
* |
359 | 359 |
*/ |
360 |
-static char const rcsid[] = "$Id: mbox.c,v 1.123 2004/09/16 08:56:19 nigelhorne Exp $"; |
|
360 |
+static char const rcsid[] = "$Id: mbox.c,v 1.124 2004/09/16 11:20:33 nigelhorne Exp $"; |
|
361 | 361 |
|
362 | 362 |
#if HAVE_CONFIG_H |
363 | 363 |
#include "clamav-config.h" |
... | ... |
@@ -1089,10 +1092,11 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t |
1089 | 1089 |
/* |
1090 | 1090 |
* Handle continuation lines |
1091 | 1091 |
* because the previous line |
1092 |
- * ended with a ; |
|
1092 |
+ * ended with a ; or this line |
|
1093 |
+ * starts with a white space |
|
1093 | 1094 |
*/ |
1094 |
- cli_dbgmsg("About to add mime Argument '%s'\n", |
|
1095 |
- line); |
|
1095 |
+ cli_dbgmsg("Multipart %d: About to add mime Argument '%s'\n", |
|
1096 |
+ multiparts, line); |
|
1096 | 1097 |
/* |
1097 | 1098 |
* Handle the case when it |
1098 | 1099 |
* isn't really a continuation |
... | ... |
@@ -1155,16 +1159,42 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t |
1155 | 1155 |
inMimeHead = continuationMarker(line); |
1156 | 1156 |
if(!inMimeHead) { |
1157 | 1157 |
const text *next = t_line->t_next; |
1158 |
+ char *fullline = strdup(line); |
|
1158 | 1159 |
|
1159 |
- if(next && next->t_line) { |
|
1160 |
+ /* |
|
1161 |
+ * Fold next lines to the end of this |
|
1162 |
+ * if they start with a white space |
|
1163 |
+ */ |
|
1164 |
+ while(next && next->t_line) { |
|
1160 | 1165 |
const char *data = lineGetData(next->t_line); |
1166 |
+ char *ptr; |
|
1167 |
+ |
|
1168 |
+ if(!isspace(data[0])) |
|
1169 |
+ break; |
|
1170 |
+ |
|
1171 |
+ ptr = cli_realloc(fullline, |
|
1172 |
+ strlen(fullline) + strlen(data) + 1); |
|
1173 |
+ |
|
1174 |
+ if(ptr == NULL) |
|
1175 |
+ break; |
|
1161 | 1176 |
|
1162 |
- if((data[0] == '\t') || (data[0] == ' ')) |
|
1163 |
- inMimeHead = TRUE; |
|
1177 |
+ fullline = ptr; |
|
1178 |
+ strcat(fullline, data); |
|
1179 |
+ |
|
1180 |
+ t_line = next; |
|
1181 |
+ next = next->t_next; |
|
1164 | 1182 |
} |
1165 |
- } |
|
1183 |
+ cli_dbgmsg("Multipart %d: About to parse folded header '%s'\n", |
|
1184 |
+ multiparts, fullline); |
|
1166 | 1185 |
|
1167 |
- parseEmailHeader(aMessage, line, rfc821Table); |
|
1186 |
+ parseEmailHeader(aMessage, fullline, rfc821Table); |
|
1187 |
+ free(fullline); |
|
1188 |
+ } else { |
|
1189 |
+ cli_dbgmsg("Multipart %d: About to parse header '%s'\n", |
|
1190 |
+ multiparts, line); |
|
1191 |
+ |
|
1192 |
+ parseEmailHeader(aMessage, line, rfc821Table); |
|
1193 |
+ } |
|
1168 | 1194 |
} else if(boundaryStart(line, boundary)) { |
1169 | 1195 |
inhead = 1; |
1170 | 1196 |
break; |
... | ... |
@@ -2099,7 +2129,7 @@ parseMimeHeader(message *m, const char *cmd, const table_t *rfc821Table, const c |
2099 | 2099 |
* "Note also that a subtype specification is |
2100 | 2100 |
* MANDATORY. There are no default subtypes" |
2101 | 2101 |
* |
2102 |
- * We have to break this an make an assumption |
|
2102 |
+ * We have to break this and make an assumption |
|
2103 | 2103 |
* for the subtype because virus writers and |
2104 | 2104 |
* email client writers don't get it right |
2105 | 2105 |
*/ |