git-svn: trunk@1947
Nigel Horne authored on 2006/05/03 18:36:40... | ... |
@@ -16,7 +16,7 @@ |
16 | 16 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
17 | 17 |
* MA 02110-1301, USA. |
18 | 18 |
*/ |
19 |
-static char const rcsid[] = "$Id: blob.c,v 1.44 2006/04/09 19:59:27 kojm Exp $"; |
|
19 |
+static char const rcsid[] = "$Id: blob.c,v 1.45 2006/05/03 09:36:40 nigelhorne Exp $"; |
|
20 | 20 |
|
21 | 21 |
#if HAVE_CONFIG_H |
22 | 22 |
#include "clamav-config.h" |
... | ... |
@@ -34,9 +34,10 @@ static char const rcsid[] = "$Id: blob.c,v 1.44 2006/04/09 19:59:27 kojm Exp $"; |
34 | 34 |
#include <sys/types.h> |
35 | 35 |
#endif |
36 | 36 |
|
37 |
+#include "others.h" |
|
37 | 38 |
#include "mbox.h" |
38 | 39 |
#include "blob.h" |
39 |
-#include "others.h" |
|
40 |
+#include "matcher.h" |
|
40 | 41 |
|
41 | 42 |
#ifndef CL_DEBUG |
42 | 43 |
#define NDEBUG /* map CLAMAV debug onto standard */ |
... | ... |
@@ -460,6 +461,21 @@ fileblobAddData(fileblob *fb, const unsigned char *data, size_t len) |
460 | 460 |
assert(data != NULL); |
461 | 461 |
|
462 | 462 |
if(fb->fp) { |
463 |
+#if 0 |
|
464 |
+ extern cli_ctx *current_ctx; |
|
465 |
+ |
|
466 |
+ if(current_ctx) { |
|
467 |
+ if(current_ctx->scanned) |
|
468 |
+ *current_ctx->scanned += len / CL_COUNT_PRECISION; |
|
469 |
+ |
|
470 |
+ if(cli_scanbuff((char *) data, len, current_ctx->virname, current_ctx->engine, 0) == CL_VIRUS) { |
|
471 |
+ cli_dbgmsg("found %s\n", *current_ctx->virname); |
|
472 |
+ /*ret = CL_VIRUS; |
|
473 |
+ break;*/ |
|
474 |
+ } |
|
475 |
+ } |
|
476 |
+#endif |
|
477 |
+ |
|
463 | 478 |
if(fwrite(data, len, 1, fb->fp) != 1) { |
464 | 479 |
cli_errmsg("fileblobAddData: Can't write %u bytes to temporary file %s: %s\n", len, fb->b.name, strerror(errno)); |
465 | 480 |
return -1; |
... | ... |
@@ -16,7 +16,7 @@ |
16 | 16 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
17 | 17 |
* MA 02110-1301, USA. |
18 | 18 |
*/ |
19 |
-static char const rcsid[] = "$Id: mbox.c,v 1.293 2006/05/02 15:19:24 nigelhorne Exp $"; |
|
19 |
+static char const rcsid[] = "$Id: mbox.c,v 1.294 2006/05/03 09:36:40 nigelhorne Exp $"; |
|
20 | 20 |
|
21 | 21 |
#if HAVE_CONFIG_H |
22 | 22 |
#include "clamav-config.h" |
... | ... |
@@ -54,16 +54,16 @@ static char const rcsid[] = "$Id: mbox.c,v 1.293 2006/05/02 15:19:24 nigelhorne |
54 | 54 |
#include <pthread.h> |
55 | 55 |
#endif |
56 | 56 |
|
57 |
+#include "others.h" |
|
58 |
+#include "defaults.h" |
|
59 |
+#include "str.h" |
|
60 |
+#include "filetypes.h" |
|
57 | 61 |
#include "table.h" |
58 | 62 |
#include "mbox.h" |
59 | 63 |
#include "blob.h" |
60 | 64 |
#include "line.h" |
61 | 65 |
#include "text.h" |
62 | 66 |
#include "message.h" |
63 |
-#include "others.h" |
|
64 |
-#include "defaults.h" |
|
65 |
-#include "str.h" |
|
66 |
-#include "filetypes.h" |
|
67 | 67 |
#include "uuencode.h" |
68 | 68 |
|
69 | 69 |
#ifdef CL_DEBUG |
... | ... |
@@ -176,11 +176,11 @@ typedef enum { FALSE = 0, TRUE = 1 } bool; |
176 | 176 |
* of EICAR within bounces, which don't metter |
177 | 177 |
*/ |
178 | 178 |
|
179 |
-static int cli_parse_mbox(const char *dir, int desc, unsigned int options); |
|
179 |
+static int cli_parse_mbox(const char *dir, int desc, cli_ctx *ctx); |
|
180 | 180 |
static message *parseEmailFile(FILE *fin, const table_t *rfc821Table, const char *firstLine, const char *dir); |
181 | 181 |
static message *parseEmailHeaders(const message *m, const table_t *rfc821Table); |
182 | 182 |
static int parseEmailHeader(message *m, const char *line, const table_t *rfc821Table); |
183 |
-static int parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t *rfc821Table, const table_t *subtypeTable, unsigned int options); |
|
183 |
+static int parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t *rfc821Table, const table_t *subtypeTable, cli_ctx *ctx); |
|
184 | 184 |
static int boundaryStart(const char *line, const char *boundary); |
185 | 185 |
static int endOfMessage(const char *line, const char *boundary); |
186 | 186 |
static int initialiseTables(table_t **rfc821Table, table_t **subtypeTable); |
... | ... |
@@ -375,7 +375,7 @@ static void free_map(void); |
375 | 375 |
* FIXME: Doesn't catch all phishes |
376 | 376 |
*/ |
377 | 377 |
int |
378 |
-cli_mbox(const char *dir, int desc, unsigned int options) |
|
378 |
+cli_mbox(const char *dir, int desc, cli_ctx *ctx) |
|
379 | 379 |
{ |
380 | 380 |
char *start, *ptr, *line; |
381 | 381 |
const char *last, *p, *q; |
... | ... |
@@ -401,7 +401,7 @@ cli_mbox(const char *dir, int desc, unsigned int options) |
401 | 401 |
|
402 | 402 |
#ifdef NW_MAX_FILE_SIZE |
403 | 403 |
if(size > NW_MAX_FILE_SIZE) |
404 |
- return cli_parse_mbox(dir, desc, options); |
|
404 |
+ return cli_parse_mbox(dir, desc, ctx); |
|
405 | 405 |
#endif |
406 | 406 |
|
407 | 407 |
/*cli_warnmsg("NEW_WORLD is new code - use at your own risk.\n");*/ |
... | ... |
@@ -505,7 +505,7 @@ cli_mbox(const char *dir, int desc, unsigned int options) |
505 | 505 |
munmap(start, size); |
506 | 506 |
|
507 | 507 |
free_map(); |
508 |
- return cli_parse_mbox(dir, desc, options); |
|
508 |
+ return cli_parse_mbox(dir, desc, ctx); |
|
509 | 509 |
#endif |
510 | 510 |
} |
511 | 511 |
|
... | ... |
@@ -546,14 +546,14 @@ cli_mbox(const char *dir, int desc, unsigned int options) |
546 | 546 |
else |
547 | 547 |
cli_dbgmsg("cli_mbox: unknown encoder, type %d\n", type); |
548 | 548 |
if(type == CL_TYPE_MAIL) |
549 |
- return cli_parse_mbox(dir, desc, options); |
|
549 |
+ return cli_parse_mbox(dir, desc, ctx); |
|
550 | 550 |
cli_dbgmsg("Unknown filetype %d, return CLEAN\n", type); |
551 | 551 |
return CL_CLEAN; |
552 | 552 |
} |
553 | 553 |
|
554 | 554 |
/* The message could be a plain text phish */ |
555 |
- if((type == CL_TYPE_MAIL) && (!(options&CL_DB_NOPHISHING))) |
|
556 |
- return cli_parse_mbox(dir, desc, options); |
|
555 |
+ if((type == CL_TYPE_MAIL) && (!(ctx->options&CL_DB_NOPHISHING))) |
|
556 |
+ return cli_parse_mbox(dir, desc, ctx); |
|
557 | 557 |
cli_dbgmsg("cli_mbox: I believe it's plain text which must be clean\n"); |
558 | 558 |
return CL_CLEAN; |
559 | 559 |
} |
... | ... |
@@ -883,7 +883,7 @@ cli_mbox(const char *dir, int desc, unsigned int options) |
883 | 883 |
cli_dbgmsg("New world - don't know what to do - fall back to old world\n"); |
884 | 884 |
/* Fall back for now */ |
885 | 885 |
lseek(desc, 0L, SEEK_SET); |
886 |
- return cli_parse_mbox(dir, desc, options); |
|
886 |
+ return cli_parse_mbox(dir, desc, ctx); |
|
887 | 887 |
} |
888 | 888 |
|
889 | 889 |
static void |
... | ... |
@@ -961,13 +961,13 @@ free_map(void) |
961 | 961 |
|
962 | 962 |
#else /*!NEW_WORLD*/ |
963 | 963 |
int |
964 |
-cli_mbox(const char *dir, int desc, unsigned int options) |
|
964 |
+cli_mbox(const char *dir, int desc, cli_ctx *ctx) |
|
965 | 965 |
{ |
966 | 966 |
if(dir == NULL) { |
967 | 967 |
cli_warnmsg("cli_mbox called with NULL dir\n"); |
968 | 968 |
return CL_ENULLARG; |
969 | 969 |
} |
970 |
- return cli_parse_mbox(dir, desc, options); |
|
970 |
+ return cli_parse_mbox(dir, desc, ctx); |
|
971 | 971 |
} |
972 | 972 |
#endif |
973 | 973 |
|
... | ... |
@@ -987,7 +987,7 @@ cli_mbox(const char *dir, int desc, unsigned int options) |
987 | 987 |
* e.g. \0Content-Type: application/binary; |
988 | 988 |
*/ |
989 | 989 |
static int |
990 |
-cli_parse_mbox(const char *dir, int desc, unsigned int options) |
|
990 |
+cli_parse_mbox(const char *dir, int desc, cli_ctx *ctx) |
|
991 | 991 |
{ |
992 | 992 |
int retcode, i; |
993 | 993 |
message *body; |
... | ... |
@@ -1135,7 +1135,7 @@ cli_parse_mbox(const char *dir, int desc, unsigned int options) |
1135 | 1135 |
} |
1136 | 1136 |
messageDestroy(m); |
1137 | 1137 |
if(messageGetBody(body)) |
1138 |
- if(!parseEmailBody(body, NULL, dir, rfc821, subtype, options)) { |
|
1138 |
+ if(!parseEmailBody(body, NULL, dir, rfc821, subtype, ctx)) { |
|
1139 | 1139 |
messageReset(body); |
1140 | 1140 |
m = body; |
1141 | 1141 |
continue; |
... | ... |
@@ -1205,7 +1205,7 @@ cli_parse_mbox(const char *dir, int desc, unsigned int options) |
1205 | 1205 |
* Write out the last entry in the mailbox |
1206 | 1206 |
*/ |
1207 | 1207 |
if(messageGetBody(body)) |
1208 |
- if(!parseEmailBody(body, NULL, dir, rfc821, subtype, options)) |
|
1208 |
+ if(!parseEmailBody(body, NULL, dir, rfc821, subtype, ctx)) |
|
1209 | 1209 |
retcode = CL_EFORMAT; |
1210 | 1210 |
|
1211 | 1211 |
/* |
... | ... |
@@ -1722,7 +1722,7 @@ parseEmailHeader(message *m, const char *line, const table_t *rfc821) |
1722 | 1722 |
* 2 for success, attachments not saved |
1723 | 1723 |
*/ |
1724 | 1724 |
static int /* success or fail */ |
1725 |
-parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t *rfc821Table, const table_t *subtypeTable, unsigned int options) |
|
1725 |
+parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t *rfc821Table, const table_t *subtypeTable, cli_ctx *ctx) |
|
1726 | 1726 |
{ |
1727 | 1727 |
message **messages; /* parts of a multipart message */ |
1728 | 1728 |
int inMimeHead, i, rc = 1, htmltextPart, multiparts = 0; |
... | ... |
@@ -1784,7 +1784,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t |
1784 | 1784 |
break; |
1785 | 1785 |
case TEXT: |
1786 | 1786 |
/* text/plain has been preprocessed as no encoding */ |
1787 |
- if((options&CL_SCAN_MAILURL) && (subtype == HTML)) |
|
1787 |
+ if((ctx->options&CL_SCAN_MAILURL) && (subtype == HTML)) |
|
1788 | 1788 |
checkURLs(mainMessage, dir); |
1789 | 1789 |
break; |
1790 | 1790 |
case MULTIPART: |
... | ... |
@@ -2220,7 +2220,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t |
2220 | 2220 |
if(htmltextPart == -1) |
2221 | 2221 |
cli_dbgmsg("No HTML code found to be scanned"); |
2222 | 2222 |
else { |
2223 |
- rc = parseEmailBody(aMessage, aText, dir, rfc821Table, subtypeTable, options); |
|
2223 |
+ rc = parseEmailBody(aMessage, aText, dir, rfc821Table, subtypeTable, ctx); |
|
2224 | 2224 |
if(rc == 1) { |
2225 | 2225 |
assert(aMessage == messages[htmltextPart]); |
2226 | 2226 |
messageDestroy(aMessage); |
... | ... |
@@ -2388,7 +2388,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t |
2388 | 2388 |
free(filename); |
2389 | 2389 |
} |
2390 | 2390 |
} else { |
2391 |
- if(options&CL_SCAN_MAILURL) |
|
2391 |
+ if(ctx->options&CL_SCAN_MAILURL) |
|
2392 | 2392 |
if(tableFind(subtypeTable, cptr) == HTML) |
2393 | 2393 |
checkURLs(aMessage, dir); |
2394 | 2394 |
messageAddArgument(aMessage, "filename=mixedtextportion"); |
... | ... |
@@ -2455,7 +2455,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t |
2455 | 2455 |
messageDestroy(messages[i]); |
2456 | 2456 |
messages[i] = NULL; |
2457 | 2457 |
if(body) { |
2458 |
- rc = parseEmailBody(body, NULL, dir, rfc821Table, subtypeTable, options); |
|
2458 |
+ rc = parseEmailBody(body, NULL, dir, rfc821Table, subtypeTable, ctx); |
|
2459 | 2459 |
messageDestroy(body); |
2460 | 2460 |
} |
2461 | 2461 |
#endif |
... | ... |
@@ -2472,13 +2472,13 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t |
2472 | 2472 |
* The headers were parsed when reading in the |
2473 | 2473 |
* whole multipart section |
2474 | 2474 |
*/ |
2475 |
- rc = parseEmailBody(aMessage, aText, dir, rfc821Table, subtypeTable, options); |
|
2475 |
+ rc = parseEmailBody(aMessage, aText, dir, rfc821Table, subtypeTable, ctx); |
|
2476 | 2476 |
cli_dbgmsg("Finished recursion\n"); |
2477 | 2477 |
assert(aMessage == messages[i]); |
2478 | 2478 |
messageDestroy(messages[i]); |
2479 | 2479 |
messages[i] = NULL; |
2480 | 2480 |
} else { |
2481 |
- rc = parseEmailBody(NULL, NULL, dir, rfc821Table, subtypeTable, options); |
|
2481 |
+ rc = parseEmailBody(NULL, NULL, dir, rfc821Table, subtypeTable, ctx); |
|
2482 | 2482 |
if(mainMessage && (mainMessage != messageIn)) |
2483 | 2483 |
messageDestroy(mainMessage); |
2484 | 2484 |
mainMessage = NULL; |
... | ... |
@@ -2504,7 +2504,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t |
2504 | 2504 |
messages[i] = NULL; |
2505 | 2505 |
} |
2506 | 2506 |
|
2507 |
- /* rc = parseEmailBody(NULL, NULL, dir, rfc821Table, subtypeTable, options); */ |
|
2507 |
+ /* rc = parseEmailBody(NULL, NULL, dir, rfc821Table, subtypeTable, ctx); */ |
|
2508 | 2508 |
break; |
2509 | 2509 |
case SIGNED: |
2510 | 2510 |
case PARALLEL: |
... | ... |
@@ -2520,7 +2520,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t |
2520 | 2520 |
if(htmltextPart == -1) |
2521 | 2521 |
htmltextPart = 0; |
2522 | 2522 |
|
2523 |
- rc = parseEmailBody(messages[htmltextPart], aText, dir, rfc821Table, subtypeTable, options); |
|
2523 |
+ rc = parseEmailBody(messages[htmltextPart], aText, dir, rfc821Table, subtypeTable, ctx); |
|
2524 | 2524 |
break; |
2525 | 2525 |
case ENCRYPTED: |
2526 | 2526 |
rc = 0; |
... | ... |
@@ -2591,7 +2591,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t |
2591 | 2591 |
} else |
2592 | 2592 |
messageReset(mainMessage); |
2593 | 2593 |
if(messageGetBody(m)) |
2594 |
- rc = parseEmailBody(m, NULL, dir, rfc821Table, subtypeTable, options); |
|
2594 |
+ rc = parseEmailBody(m, NULL, dir, rfc821Table, subtypeTable, ctx); |
|
2595 | 2595 |
|
2596 | 2596 |
messageDestroy(m); |
2597 | 2597 |
} |
... | ... |
@@ -16,7 +16,7 @@ |
16 | 16 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
17 | 17 |
* MA 02110-1301, USA. |
18 | 18 |
*/ |
19 |
-static char const rcsid[] = "$Id: message.c,v 1.165 2006/05/02 15:19:24 nigelhorne Exp $"; |
|
19 |
+static char const rcsid[] = "$Id: message.c,v 1.166 2006/05/03 09:36:40 nigelhorne Exp $"; |
|
20 | 20 |
|
21 | 21 |
#if HAVE_CONFIG_H |
22 | 22 |
#include "clamav-config.h" |
... | ... |
@@ -46,15 +46,16 @@ static char const rcsid[] = "$Id: message.c,v 1.165 2006/05/02 15:19:24 nigelhor |
46 | 46 |
#include <pthread.h> |
47 | 47 |
#endif |
48 | 48 |
|
49 |
+#include "others.h" |
|
50 |
+#include "str.h" |
|
51 |
+#include "filetypes.h" |
|
52 |
+ |
|
49 | 53 |
#include "line.h" |
50 | 54 |
#include "mbox.h" |
51 | 55 |
#include "table.h" |
52 | 56 |
#include "blob.h" |
53 | 57 |
#include "text.h" |
54 | 58 |
#include "strrcpy.h" |
55 |
-#include "others.h" |
|
56 |
-#include "str.h" |
|
57 |
-#include "filetypes.h" |
|
58 | 59 |
|
59 | 60 |
/* required for AIX and Tru64 */ |
60 | 61 |
#ifdef TRUE |
... | ... |
@@ -45,8 +45,6 @@ |
45 | 45 |
|
46 | 46 |
extern short cli_leavetemps_flag; |
47 | 47 |
|
48 |
-extern int cli_mbox(const char *dir, int desc, unsigned int options); /* FIXME */ |
|
49 |
- |
|
50 | 48 |
#include "clamav.h" |
51 | 49 |
#include "others.h" |
52 | 50 |
#include "scanners.h" |
... | ... |
@@ -97,6 +95,7 @@ extern int cli_mbox(const char *dir, int desc, unsigned int options); /* FIXME * |
97 | 97 |
|
98 | 98 |
#define MAX_MAIL_RECURSION 15 |
99 | 99 |
|
100 |
+extern int cli_mbox(const char *dir, int desc, cli_ctx *ctx); /* FIXME */ |
|
100 | 101 |
static int cli_scanfile(const char *filename, cli_ctx *ctx); |
101 | 102 |
|
102 | 103 |
/* |
... | ... |
@@ -1513,7 +1512,7 @@ static int cli_scanmail(int desc, cli_ctx *ctx) |
1513 | 1513 |
/* |
1514 | 1514 |
* Extract the attachments into the temporary directory |
1515 | 1515 |
*/ |
1516 |
- if((ret = cli_mbox(dir, desc, ctx->options))) { |
|
1516 |
+ if((ret = cli_mbox(dir, desc, ctx))) { |
|
1517 | 1517 |
if(!cli_leavetemps_flag) |
1518 | 1518 |
cli_rmdirs(dir); |
1519 | 1519 |
free(dir); |
... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* MA 02110-1301, USA. |
18 | 18 |
* |
19 | 19 |
* $Log: text.c,v $ |
20 |
+ * Revision 1.17 2006/05/03 09:36:40 nigelhorne |
|
21 |
+ * Pass full ctx into the mbox code |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.16 2006/04/09 19:59:28 kojm |
21 | 24 |
* update GPL headers with new address for FSF |
22 | 25 |
* |
... | ... |
@@ -58,7 +61,7 @@ |
58 | 58 |
* |
59 | 59 |
*/ |
60 | 60 |
|
61 |
-static char const rcsid[] = "$Id: text.c,v 1.16 2006/04/09 19:59:28 kojm Exp $"; |
|
61 |
+static char const rcsid[] = "$Id: text.c,v 1.17 2006/05/03 09:36:40 nigelhorne Exp $"; |
|
62 | 62 |
|
63 | 63 |
#if HAVE_CONFIG_H |
64 | 64 |
#include "clamav-config.h" |
... | ... |
@@ -84,11 +87,11 @@ static char const rcsid[] = "$Id: text.c,v 1.16 2006/04/09 19:59:28 kojm Exp $"; |
84 | 84 |
#include <assert.h> |
85 | 85 |
#include <stdio.h> |
86 | 86 |
|
87 |
+#include "others.h" |
|
87 | 88 |
#include "line.h" |
88 | 89 |
#include "mbox.h" |
89 | 90 |
#include "blob.h" |
90 | 91 |
#include "text.h" |
91 |
-#include "others.h" |
|
92 | 92 |
|
93 | 93 |
static text *textCopy(const text *t_head); |
94 | 94 |
static void addToFileblob(const line_t *line, void *arg); |