git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@1316 77e5149b-7576-45b1-b177-96237e5ba77b
Nigel Horne authored on 2005/02/07 03:25:10... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Sun Feb 6 18:23:15 GMT 2005 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav/mbox.c: Some W95.Matrix.SCR were not being caught. Reported by |
|
4 |
+ Stefan Kaltenbrunner <stefan@kaltenbrunner.cc> |
|
5 |
+ |
|
1 | 6 |
Sun Feb 6 10:41:48 GMT 2005 (njh) |
2 | 7 |
---------------------------------- |
3 | 8 |
* clamav-milter: Up-issue to 0.82 |
... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: mbox.c,v $ |
20 |
+ * Revision 1.218 2005/02/06 18:21:18 nigelhorne |
|
21 |
+ * Some W95.Matrix.SCR were not being found |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.217 2005/02/06 09:45:53 nigelhorne |
21 | 24 |
* Speed up the (not implemented) next generation of mbox code |
22 | 25 |
* |
... | ... |
@@ -639,7 +642,7 @@ |
639 | 639 |
* Compilable under SCO; removed duplicate code with message.c |
640 | 640 |
* |
641 | 641 |
*/ |
642 |
-static char const rcsid[] = "$Id: mbox.c,v 1.217 2005/02/06 09:45:53 nigelhorne Exp $"; |
|
642 |
+static char const rcsid[] = "$Id: mbox.c,v 1.218 2005/02/06 18:21:18 nigelhorne Exp $"; |
|
643 | 643 |
|
644 | 644 |
#if HAVE_CONFIG_H |
645 | 645 |
#include "clamav-config.h" |
... | ... |
@@ -1017,6 +1020,7 @@ cli_mbox(const char *dir, int desc, unsigned int options) |
1017 | 1017 |
memcpy(buf, ptr, bodysize); |
1018 | 1018 |
munmap(start, size); |
1019 | 1019 |
ptr = start = buf; |
1020 |
+ last = &start[size - 1]; |
|
1020 | 1021 |
} else |
1021 | 1022 |
wasAlloced = 0; |
1022 | 1023 |
|
... | ... |
@@ -1024,13 +1028,17 @@ cli_mbox(const char *dir, int desc, unsigned int options) |
1024 | 1024 |
cli_dbgmsg("Header base64\n"); |
1025 | 1025 |
decoder |= 1; |
1026 | 1026 |
b64start = &p[6]; |
1027 |
+ cli_dbgmsg("last 0x%p b64start 0x%p\n", last, b64start); |
|
1027 | 1028 |
b64size = (size_t)(last - b64start) + 1; |
1029 |
+ assert(b64size <= size); |
|
1028 | 1030 |
} |
1029 | 1031 |
if((p = (char *)cli_pmemstr(ptr, bodysize, "quoted-printable", 16)) != NULL) { |
1030 | 1032 |
cli_dbgmsg("Header quoted-printable\n"); |
1031 | 1033 |
decoder |= 2; |
1032 |
- quotedstart = p; |
|
1034 |
+ quotedstart = &p[16]; |
|
1035 |
+ cli_dbgmsg("last 0x%p quotedstart 0x%p\n", last, quotedstart); |
|
1033 | 1036 |
quotedsize = (size_t)(last - quotedstart) + 1; |
1037 |
+ assert(quotedsize <= size); |
|
1034 | 1038 |
} |
1035 | 1039 |
if(!(decoder&1)) |
1036 | 1040 |
if((p = (char *)cli_pmemstr(ptr, bodysize, "base64", 6)) != NULL) { |
... | ... |
@@ -1038,6 +1046,7 @@ cli_mbox(const char *dir, int desc, unsigned int options) |
1038 | 1038 |
decoder |= 1; |
1039 | 1039 |
b64start = &p[6]; |
1040 | 1040 |
b64size = (unsigned long)(last - b64start) + 1; |
1041 |
+ assert(b64size <= size); |
|
1041 | 1042 |
} |
1042 | 1043 |
if(!(decoder&2)) |
1043 | 1044 |
if((p = (char *)cli_pmemstr(ptr, bodysize, "quoted-printable", 16)) != NULL) { |
... | ... |
@@ -1045,6 +1054,7 @@ cli_mbox(const char *dir, int desc, unsigned int options) |
1045 | 1045 |
decoder |= 2; |
1046 | 1046 |
quotedstart = &p[16]; |
1047 | 1047 |
quotedsize = (unsigned long)(last - quotedstart) + 1; |
1048 |
+ assert(quotedsize <= size); |
|
1048 | 1049 |
} |
1049 | 1050 |
|
1050 | 1051 |
if(decoder == 0) { |
... | ... |
@@ -1052,12 +1062,12 @@ cli_mbox(const char *dir, int desc, unsigned int options) |
1052 | 1052 |
free(start); |
1053 | 1053 |
else |
1054 | 1054 |
munmap(start, size); |
1055 |
- cli_dbgmsg("cli_mbox: unknown encoder\n"); |
|
1056 |
- printf("cli_mbox: unknown encoder\n"); |
|
1055 |
+ cli_warnmsg("cli_mbox: unknown encoder\n"); |
|
1057 | 1056 |
return cli_parse_mbox(dir, desc, options); |
1058 | 1057 |
} |
1059 | 1058 |
|
1060 | 1059 |
if(b64start) { |
1060 |
+ cli_dbgmsg("b64size = %lu\n", b64size); |
|
1061 | 1061 |
while(*b64start != '\n') { |
1062 | 1062 |
b64start++; |
1063 | 1063 |
b64size--; |
... | ... |
@@ -1082,16 +1092,17 @@ cli_mbox(const char *dir, int desc, unsigned int options) |
1082 | 1082 |
b64size--; |
1083 | 1083 |
} |
1084 | 1084 |
|
1085 |
- while(!isalnum(*b64start)) { |
|
1086 |
- b64start++; |
|
1087 |
- b64size--; |
|
1088 |
- } |
|
1085 |
+ if(b64size > 0L) |
|
1086 |
+ while(!isalnum(*b64start)) { |
|
1087 |
+ if(b64size-- == 0L) |
|
1088 |
+ break; |
|
1089 |
+ b64start++; |
|
1090 |
+ } |
|
1089 | 1091 |
|
1090 | 1092 |
if(b64size > 0L) { |
1091 | 1093 |
cli_dbgmsg("cli_mbox: decoding %ld base64 bytes\n", b64size); |
1092 | 1094 |
|
1093 | 1095 |
line = NULL; |
1094 |
- length = 0; |
|
1095 | 1096 |
|
1096 | 1097 |
m = messageCreate(); |
1097 | 1098 |
if(m == NULL) |
... | ... |
@@ -1101,7 +1112,7 @@ cli_mbox(const char *dir, int desc, unsigned int options) |
1101 | 1101 |
while(b64size > 0L) { |
1102 | 1102 |
length = 0; |
1103 | 1103 |
|
1104 |
- /*printf("%ld: ", bytesleft); fflush(stdout);*/ |
|
1104 |
+ /*printf("%ld: ", b64size); fflush(stdout);*/ |
|
1105 | 1105 |
|
1106 | 1106 |
for(ptr = b64start; b64size && (*ptr != '\n') && (*ptr != '\r'); ptr++) { |
1107 | 1107 |
length++; |
... | ... |
@@ -1129,6 +1140,7 @@ cli_mbox(const char *dir, int desc, unsigned int options) |
1129 | 1129 |
if(strchr(line, '=')) |
1130 | 1130 |
break; |
1131 | 1131 |
} |
1132 |
+ free(line); |
|
1132 | 1133 |
fb = messageToFileblob(m, dir); |
1133 | 1134 |
messageDestroy(m); |
1134 | 1135 |
|
... | ... |
@@ -1139,6 +1151,7 @@ cli_mbox(const char *dir, int desc, unsigned int options) |
1139 | 1139 |
} |
1140 | 1140 |
} |
1141 | 1141 |
if(quotedstart) { |
1142 |
+ cli_dbgmsg("quotedsize = %lu\n", quotedsize); |
|
1142 | 1143 |
while(*quotedstart != '\n') { |
1143 | 1144 |
quotedstart++; |
1144 | 1145 |
quotedsize--; |
... | ... |
@@ -1177,12 +1190,11 @@ cli_mbox(const char *dir, int desc, unsigned int options) |
1177 | 1177 |
messageSetEncoding(m, "quoted-printable"); |
1178 | 1178 |
|
1179 | 1179 |
line = NULL; |
1180 |
- length = 0; |
|
1181 | 1180 |
|
1182 | 1181 |
while(quotedsize > 0L) { |
1183 | 1182 |
length = 0; |
1184 | 1183 |
|
1185 |
- /*printf("%ld: ", bytesleft); fflush(stdout);*/ |
|
1184 |
+ /*printf("%ld: ", quotedsize); fflush(stdout);*/ |
|
1186 | 1185 |
|
1187 | 1186 |
for(ptr = quotedstart; quotedsize && (*ptr != '\n') && (*ptr != '\r'); ptr++) { |
1188 | 1187 |
length++; |
... | ... |
@@ -1208,6 +1220,7 @@ cli_mbox(const char *dir, int desc, unsigned int options) |
1208 | 1208 |
quotedstart = ++ptr; |
1209 | 1209 |
--quotedsize; |
1210 | 1210 |
} |
1211 |
+ free(line); |
|
1211 | 1212 |
fb = messageToFileblob(m, dir); |
1212 | 1213 |
messageDestroy(m); |
1213 | 1214 |
|
... | ... |
@@ -2152,6 +2165,14 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t |
2152 | 2152 |
next = t_line->t_next; |
2153 | 2153 |
if(next && next->t_line) { |
2154 | 2154 |
const char *data = lineGetData(next->t_line); |
2155 |
+ |
|
2156 |
+ if((messageGetEncoding(aMessage) == NOENCODING) && |
|
2157 |
+ (messageGetMimeType(aMessage) == APPLICATION)) |
|
2158 |
+ if(strstr(data, "base64")) { |
|
2159 |
+ messageSetEncoding(aMessage, "base64"); |
|
2160 |
+ cli_dbgmsg("Ignoring fake end of headers\n"); |
|
2161 |
+ continue; |
|
2162 |
+ } |
|
2155 | 2163 |
if(strncmp(data, "Content", 7) == 0) { |
2156 | 2164 |
cli_dbgmsg("Ignoring fake end of headers\n"); |
2157 | 2165 |
continue; |