git-svn: trunk@1010
Nigel Horne authored on 2004/10/17 02:26:41... | ... |
@@ -1,3 +1,9 @@ |
1 |
+Sat Oct 16 18:24:33 BST 2004 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav/mbox.c: Handle headers such as boundary="=.J:gysAG)N(3_zv" |
|
4 |
+ where the colon must not be treated as a |
|
5 |
+ token separator, reported by Christoph |
|
6 |
+ |
|
1 | 7 |
Sat Oct 16 17:10:06 BST 2004 (njh) |
2 | 8 |
---------------------------------- |
3 | 9 |
* libclamav/untar.c: Handle empty files in the middle of archives, reported |
... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: mbox.c,v $ |
20 |
+ * Revision 1.155 2004/10/16 17:23:04 nigelhorne |
|
21 |
+ * Handle colons in quotes in headers |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.154 2004/10/16 09:01:05 nigelhorne |
21 | 24 |
* Improved handling of wraparound headers |
22 | 25 |
* |
... | ... |
@@ -450,7 +453,7 @@ |
450 | 450 |
* Compilable under SCO; removed duplicate code with message.c |
451 | 451 |
* |
452 | 452 |
*/ |
453 |
-static char const rcsid[] = "$Id: mbox.c,v 1.154 2004/10/16 09:01:05 nigelhorne Exp $"; |
|
453 |
+static char const rcsid[] = "$Id: mbox.c,v 1.155 2004/10/16 17:23:04 nigelhorne Exp $"; |
|
454 | 454 |
|
455 | 455 |
#if HAVE_CONFIG_H |
456 | 456 |
#include "clamav-config.h" |
... | ... |
@@ -948,8 +951,9 @@ parseEmailHeaders(const message *m, const table_t *rfc821) |
948 | 948 |
* |
949 | 949 |
* Add all the arguments on the line |
950 | 950 |
*/ |
951 |
- const char *ptr; |
|
951 |
+ char *ptr; |
|
952 | 952 |
char copy[LINE_LENGTH + 1]; |
953 |
+ bool inquotes = FALSE; |
|
953 | 954 |
#ifdef CL_THREAD_SAFE |
954 | 955 |
char *strptr; |
955 | 956 |
#endif |
... | ... |
@@ -965,14 +969,34 @@ parseEmailHeaders(const message *m, const table_t *rfc821) |
965 | 965 |
assert(strlen(buffer) < sizeof(copy)); |
966 | 966 |
strcpy(copy, buffer); |
967 | 967 |
|
968 |
+ /* |
|
969 |
+ * Ensure that the colon in headers such as |
|
970 |
+ * this doesn't get mistaken for a token |
|
971 |
+ * separator |
|
972 |
+ * boundary="=.J:gysAG)N(3_zv" |
|
973 |
+ */ |
|
974 |
+ for(ptr = copy; *ptr; ptr++) |
|
975 |
+ if(*ptr == '\"') |
|
976 |
+ inquotes = !inquotes; |
|
977 |
+ else if(inquotes) |
|
978 |
+ *ptr |= '\200'; |
|
979 |
+ |
|
968 | 980 |
#ifdef CL_THREAD_SAFE |
969 | 981 |
for(ptr = strtok_r(copy, ";", &strptr); ptr; ptr = strtok_r(NULL, ":", &strptr)) |
970 |
- if(strchr(ptr, '=')) |
|
982 |
+ if(strchr(ptr, '=')) { |
|
983 |
+ char *p2; |
|
984 |
+ for(p2 = ptr; *p2; p2++) |
|
985 |
+ *p2 &= '\177'; |
|
971 | 986 |
messageAddArguments(ret, ptr); |
987 |
+ } |
|
972 | 988 |
#else |
973 | 989 |
for(ptr = strtok(copy, ";"); ptr; ptr = strtok(NULL, ":")) |
974 |
- if(strchr(ptr, '=')) |
|
990 |
+ if(strchr(ptr, '=')) { |
|
991 |
+ char *p2; |
|
992 |
+ for(p2 = ptr; *p2; p2++) |
|
993 |
+ *p2 &= '\177'; |
|
975 | 994 |
messageAddArguments(ret, ptr); |
995 |
+ } |
|
976 | 996 |
#endif |
977 | 997 |
} else { |
978 | 998 |
Xheader = (bool)(buffer[0] == 'X'); |
... | ... |
@@ -16,6 +16,9 @@ |
16 | 16 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
17 | 17 |
* |
18 | 18 |
* $Log: message.h,v $ |
19 |
+ * Revision 1.21 2004/10/16 17:24:15 nigelhorne |
|
20 |
+ * Handle colons in quotes in headers |
|
21 |
+ * |
|
19 | 22 |
* Revision 1.20 2004/10/14 17:45:55 nigelhorne |
20 | 23 |
* Try to reclaim some memory if it becomes low when decoding |
21 | 24 |
* |
... | ... |
@@ -88,12 +91,12 @@ typedef struct message { |
88 | 88 |
* Markers for the start of various non MIME messages that could |
89 | 89 |
* be included within this message |
90 | 90 |
*/ |
91 |
- text *bounce; /* start of a bounced message */ |
|
92 |
- text *binhex; /* start of a binhex message */ |
|
93 |
- text *uuencode; /* start of a uuencoded message */ |
|
94 |
- text *yenc; /* start of a yEnc message */ |
|
95 |
- text *encoding; /* is the non MIME message encoded? */ |
|
96 |
- text *dedupedThisFar; |
|
91 |
+ const text *bounce; /* start of a bounced message */ |
|
92 |
+ const text *binhex; /* start of a binhex message */ |
|
93 |
+ const text *uuencode; /* start of a uuencoded message */ |
|
94 |
+ const text *yenc; /* start of a yEnc message */ |
|
95 |
+ const text *encoding; /* is the non MIME message encoded? */ |
|
96 |
+ const text *dedupedThisFar; |
|
97 | 97 |
} message; |
98 | 98 |
|
99 | 99 |
message *messageCreate(void); |