git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@326 77e5149b-7576-45b1-b177-96237e5ba77b
Nigel Horne authored on 2004/02/23 19:14:50... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Mon Feb 23 10:19:01 GMT 2004 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav: mbox: handle spaces before the : in headers e.g. |
|
4 |
+ Content-Type : application/octet-stream; name="eicar.com" |
|
5 |
+ |
|
1 | 6 |
Mon Feb 23 00:43:44 CET 2004 (tk) |
2 | 7 |
--------------------------------- |
3 | 8 |
* libclamav: cl_rndnum: do not use buffered fread() (thanks to Nigel) |
... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: mbox.c,v $ |
20 |
+ * Revision 1.47 2004/02/23 10:13:08 nigelhorne |
|
21 |
+ * Handle spaces before : in headers |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.46 2004/02/18 13:29:19 nigelhorne |
21 | 24 |
* Stop buffer overflows for files with very long suffixes |
22 | 25 |
* |
... | ... |
@@ -129,7 +132,7 @@ |
129 | 129 |
* Compilable under SCO; removed duplicate code with message.c |
130 | 130 |
* |
131 | 131 |
*/ |
132 |
-static char const rcsid[] = "$Id: mbox.c,v 1.46 2004/02/18 13:29:19 nigelhorne Exp $"; |
|
132 |
+static char const rcsid[] = "$Id: mbox.c,v 1.47 2004/02/23 10:13:08 nigelhorne Exp $"; |
|
133 | 133 |
|
134 | 134 |
#if HAVE_CONFIG_H |
135 | 135 |
#include "clamav-config.h" |
... | ... |
@@ -229,9 +232,9 @@ static const struct tableinit { |
229 | 229 |
int value; |
230 | 230 |
} rfc821headers[] = { |
231 | 231 |
/* TODO: make these regular expressions */ |
232 |
- { "Content-Type:", CONTENT_TYPE }, |
|
233 |
- { "Content-Transfer-Encoding:", CONTENT_TRANSFER_ENCODING }, |
|
234 |
- { "Content-Disposition:", CONTENT_DISPOSITION }, |
|
232 |
+ { "Content-Type", CONTENT_TYPE }, |
|
233 |
+ { "Content-Transfer-Encoding", CONTENT_TRANSFER_ENCODING }, |
|
234 |
+ { "Content-Disposition", CONTENT_DISPOSITION }, |
|
235 | 235 |
{ NULL, 0 } |
236 | 236 |
}, mimeSubtypes[] = { |
237 | 237 |
/* subtypes of Text */ |
... | ... |
@@ -464,7 +467,6 @@ parseEmailHeaders(const message *m, const table_t *rfc821Table) |
464 | 464 |
|
465 | 465 |
/* |
466 | 466 |
* Handle a header line of an email message |
467 |
- * TODO: handle spaces before the ':' |
|
468 | 467 |
*/ |
469 | 468 |
static int |
470 | 469 |
parseEmailHeader(message *m, const char *line, const table_t *rfc821Table) |
... | ... |
@@ -478,7 +480,7 @@ parseEmailHeader(message *m, const char *line, const table_t *rfc821Table) |
478 | 478 |
|
479 | 479 |
cli_dbgmsg("parseEmailHeader '%s'\n", line); |
480 | 480 |
|
481 |
- cmd = strtok_r(copy, " \t", &strptr); |
|
481 |
+ cmd = strtok_r(copy, ":", &strptr); |
|
482 | 482 |
|
483 | 483 |
if(*cmd) { |
484 | 484 |
char *arg = strtok_r(NULL, "", &strptr); |
... | ... |
@@ -489,27 +491,9 @@ parseEmailHeader(message *m, const char *line, const table_t *rfc821Table) |
489 | 489 |
* Content-Type: multipart/mixed; |
490 | 490 |
* set arg to be |
491 | 491 |
* "multipart/mixed" and cmd to |
492 |
- * be "Content-Type:" |
|
492 |
+ * be "Content-Type" |
|
493 | 493 |
*/ |
494 | 494 |
ret = parseMimeHeader(m, cmd, rfc821Table, arg); |
495 |
- else { |
|
496 |
- /* |
|
497 |
- * Handle the case where the |
|
498 |
- * header does not have a space |
|
499 |
- * after the ':', e.g. |
|
500 |
- * Content-Type:multipart/mixed; |
|
501 |
- */ |
|
502 |
- arg = strchr(cmd, ':'); |
|
503 |
- if(arg && (*++arg != '\0')) { |
|
504 |
- char *p; |
|
505 |
- |
|
506 |
- cmd = strdup(cmd); |
|
507 |
- p = strchr(cmd, ':'); |
|
508 |
- *++p = '\0'; |
|
509 |
- ret = parseMimeHeader(m, cmd, rfc821Table, arg); |
|
510 |
- free(cmd); |
|
511 |
- } |
|
512 |
- } |
|
513 | 495 |
} |
514 | 496 |
free(copy); |
515 | 497 |
|
... | ... |
@@ -1735,7 +1719,7 @@ saveFile(const blob *b, const char *dir) |
1735 | 1735 |
|
1736 | 1736 |
if(fd < 0) { |
1737 | 1737 |
cli_errmsg("Can't create temporary file %s: %s\n", filename, strerror(errno)); |
1738 |
- printf("%d %d %d\n", suffixLen, sizeof(filename), strlen(filename)); |
|
1738 |
+ cli_dbgmsg("%lu %d %d\n", suffixLen, sizeof(filename), strlen(filename)); |
|
1739 | 1739 |
return FALSE; |
1740 | 1740 |
} |
1741 | 1741 |
|