git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@1079 77e5149b-7576-45b1-b177-96237e5ba77b
Nigel Horne authored on 2004/11/09 19:10:39... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Tue Nov 9 10:10:07 GMT 2004 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav/mbox.c: Basic handling for unbalanced quotes in the main |
|
4 |
+ message |
|
5 |
+ |
|
1 | 6 |
Tue Nov 9 08:53:24 CET 2004 (tk) |
2 | 7 |
--------------------------------- |
3 | 8 |
* clamscan, clamd: increase value of maximal recursion limit (current: 8, |
... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: mbox.c,v $ |
20 |
+ * Revision 1.170 2004/11/09 10:08:02 nigelhorne |
|
21 |
+ * Added basic handling of folded headers in the main message |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.169 2004/11/08 16:27:09 nigelhorne |
21 | 24 |
* Fix crash with correctly encoded uuencode files |
22 | 25 |
* |
... | ... |
@@ -495,7 +498,7 @@ |
495 | 495 |
* Compilable under SCO; removed duplicate code with message.c |
496 | 496 |
* |
497 | 497 |
*/ |
498 |
-static char const rcsid[] = "$Id: mbox.c,v 1.169 2004/11/08 16:27:09 nigelhorne Exp $"; |
|
498 |
+static char const rcsid[] = "$Id: mbox.c,v 1.170 2004/11/09 10:08:02 nigelhorne Exp $"; |
|
499 | 499 |
|
500 | 500 |
#if HAVE_CONFIG_H |
501 | 501 |
#include "clamav-config.h" |
... | ... |
@@ -984,6 +987,7 @@ parseEmailHeaders(const message *m, const table_t *rfc821) |
984 | 984 |
bool anyHeadersFound = FALSE; |
985 | 985 |
bool Xheader = FALSE; |
986 | 986 |
int commandNumber = -1; |
987 |
+ char *fullline = NULL; |
|
987 | 988 |
|
988 | 989 |
cli_dbgmsg("parseEmailHeaders\n"); |
989 | 990 |
|
... | ... |
@@ -1034,8 +1038,18 @@ parseEmailHeaders(const message *m, const table_t *rfc821) |
1034 | 1034 |
continue; |
1035 | 1035 |
} |
1036 | 1036 |
|
1037 |
- assert(strlen(buffer) < sizeof(copy)); |
|
1038 |
- strcpy(copy, buffer); |
|
1037 |
+ if(fullline) { |
|
1038 |
+ /* |
|
1039 |
+ * FIXME: Handle more than one line spanned by |
|
1040 |
+ * quote marks, and handle two very long lines |
|
1041 |
+ */ |
|
1042 |
+ snprintf(copy, sizeof(copy) - 1, "%s%s", fullline, buffer); |
|
1043 |
+ free(fullline); |
|
1044 |
+ fullline = NULL; |
|
1045 |
+ } else { |
|
1046 |
+ assert(strlen(buffer) < sizeof(copy)); |
|
1047 |
+ strcpy(copy, buffer); |
|
1048 |
+ } |
|
1039 | 1049 |
|
1040 | 1050 |
/* |
1041 | 1051 |
* Ensure that the colon in headers such as |
... | ... |
@@ -1073,17 +1087,34 @@ parseEmailHeaders(const message *m, const table_t *rfc821) |
1073 | 1073 |
} |
1074 | 1074 |
#endif |
1075 | 1075 |
} else { |
1076 |
+ const char *qptr; |
|
1077 |
+ int quotes = 0; |
|
1078 |
+ bool parsed = FALSE; |
|
1079 |
+ char cmd[LINE_LENGTH + 1]; |
|
1080 |
+ |
|
1076 | 1081 |
Xheader = (bool)(buffer[0] == 'X'); |
1077 | 1082 |
contMarker = continuationMarker(buffer); |
1078 |
- if((parseEmailHeader(ret, buffer, rfc821) >= 0) || |
|
1079 |
- (strncasecmp(buffer, "From ", 5) == 0)) { |
|
1080 |
- char cmd[LINE_LENGTH + 1]; |
|
1081 | 1083 |
|
1084 |
+ if(!Xheader) |
|
1085 |
+ for(qptr = buffer; *qptr; qptr++) |
|
1086 |
+ if(*qptr == '\"') |
|
1087 |
+ quotes++; |
|
1088 |
+ |
|
1089 |
+ fullline = NULL; |
|
1090 |
+ |
|
1091 |
+ if(quotes & 1) { |
|
1092 |
+ contMarker = TRUE; |
|
1093 |
+ fullline = strdup(buffer); |
|
1094 |
+ parsed = TRUE; |
|
1095 |
+ } else if((parseEmailHeader(ret, buffer, rfc821) >= 0) || |
|
1096 |
+ (strncasecmp(buffer, "From ", 5) == 0)) |
|
1097 |
+ parsed = TRUE; |
|
1098 |
+ |
|
1099 |
+ if(parsed) |
|
1082 | 1100 |
if(cli_strtokbuf(buffer, 0, ":", cmd) != NULL) { |
1083 | 1101 |
anyHeadersFound = TRUE; |
1084 | 1102 |
commandNumber = tableFind(rfc821, cmd); |
1085 | 1103 |
} |
1086 |
- } |
|
1087 | 1104 |
} |
1088 | 1105 |
} else { |
1089 | 1106 |
/*cli_dbgmsg("Add line to body '%s'\n", buffer);*/ |
... | ... |
@@ -1092,6 +1123,11 @@ parseEmailHeaders(const message *m, const table_t *rfc821) |
1092 | 1092 |
} |
1093 | 1093 |
} |
1094 | 1094 |
|
1095 |
+ if(fullline) { |
|
1096 |
+ cli_warnmsg("parseEmailHeaders: Fullline set '%s' - report to bugs@clamav.net\n"); |
|
1097 |
+ free(fullline); |
|
1098 |
+ } |
|
1099 |
+ |
|
1095 | 1100 |
if(!anyHeadersFound) { |
1096 | 1101 |
/* |
1097 | 1102 |
* False positive in believing we have an e-mail when we don't |