git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@736 77e5149b-7576-45b1-b177-96237e5ba77b
Tomasz Kojm authored on 2004/08/10 06:37:21... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Mon Aug 9 23:31:53 CEST 2004 (tk) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav: add new option CL_MAILURL |
|
4 |
+ |
|
1 | 5 |
Mon Aug 9 09:27:02 BST 2004 (njh) |
2 | 6 |
---------------------------------- |
3 | 7 |
* libclamav/mbox.c: checkURLs code (not enabled by default) is now thread |
... | ... |
@@ -60,7 +60,7 @@ |
60 | 60 |
dev_t procdev; |
61 | 61 |
#endif |
62 | 62 |
|
63 |
-extern int cli_mbox(const char *dir, int desc); /* FIXME */ |
|
63 |
+extern int cli_mbox(const char *dir, int desc, unsigned int options); /* FIXME */ |
|
64 | 64 |
|
65 | 65 |
int scanmanager(const struct optstruct *opt) |
66 | 66 |
{ |
... | ... |
@@ -257,7 +257,7 @@ int scanmanager(const struct optstruct *opt) |
257 | 257 |
/* |
258 | 258 |
* Extract the attachments into the temporary directory |
259 | 259 |
*/ |
260 |
- ret = cli_mbox(dir, 0); |
|
260 |
+ ret = cli_mbox(dir, 0, 0); |
|
261 | 261 |
|
262 | 262 |
if(ret == 0) { |
263 | 263 |
/* fix permissions of extracted files */ |
... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: mbox.c,v $ |
20 |
+ * Revision 1.95 2004/08/09 21:37:21 kojm |
|
21 |
+ * libclamav: add new option CL_MAILURL |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.94 2004/08/09 08:26:36 nigelhorne |
21 | 24 |
* Thread safe checkURL |
22 | 25 |
* |
... | ... |
@@ -270,7 +273,7 @@ |
270 | 270 |
* Compilable under SCO; removed duplicate code with message.c |
271 | 271 |
* |
272 | 272 |
*/ |
273 |
-static char const rcsid[] = "$Id: mbox.c,v 1.94 2004/08/09 08:26:36 nigelhorne Exp $"; |
|
273 |
+static char const rcsid[] = "$Id: mbox.c,v 1.95 2004/08/09 21:37:21 kojm Exp $"; |
|
274 | 274 |
|
275 | 275 |
#if HAVE_CONFIG_H |
276 | 276 |
#include "clamav-config.h" |
... | ... |
@@ -347,7 +350,7 @@ typedef enum { FALSE = 0, TRUE = 1 } bool; |
347 | 347 |
|
348 | 348 |
static message *parseEmailHeaders(message *m, const table_t *rfc821Table, bool destroy); |
349 | 349 |
static int parseEmailHeader(message *m, const char *line, const table_t *rfc821Table); |
350 |
-static int parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, const char *dir, table_t *rfc821Table, table_t *subtypeTable); |
|
350 |
+static int parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, const char *dir, table_t *rfc821Table, table_t *subtypeTable, unsigned int options); |
|
351 | 351 |
static int boundaryStart(const char *line, const char *boundary); |
352 | 352 |
static int endOfMessage(const char *line, const char *boundary); |
353 | 353 |
static int initialiseTables(table_t **rfc821Table, table_t **subtypeTable); |
... | ... |
@@ -436,7 +439,7 @@ static table_t *rfc821Table, *subtypeTable; |
436 | 436 |
#endif |
437 | 437 |
|
438 | 438 |
#define SAVE_TO_DISC /* multipart/message are saved in a temporary file */ |
439 |
-/*#define CHECKURLS /* If an email contains URLs, check them */ |
|
439 |
+#define SCAN_MAILURL (options & CL_MAILURL) |
|
440 | 440 |
|
441 | 441 |
/* |
442 | 442 |
* TODO: when signal handling is added, need to remove temp files when a |
... | ... |
@@ -454,7 +457,7 @@ static table_t *rfc821Table, *subtypeTable; |
454 | 454 |
* TODO: create parseEmail which calls parseEmailHeaders then parseEmailBody |
455 | 455 |
*/ |
456 | 456 |
int |
457 |
-cli_mbox(const char *dir, int desc) |
|
457 |
+cli_mbox(const char *dir, int desc, unsigned int options) |
|
458 | 458 |
{ |
459 | 459 |
int retcode, i; |
460 | 460 |
message *m, *body; |
... | ... |
@@ -532,7 +535,7 @@ cli_mbox(const char *dir, int desc) |
532 | 532 |
body = parseEmailHeaders(m, rfc821Table, TRUE); |
533 | 533 |
messageDestroy(m); |
534 | 534 |
if(messageGetBody(body)) |
535 |
- if(!parseEmailBody(body, NULL, 0, NULL, dir, rfc821Table, subtypeTable)) { |
|
535 |
+ if(!parseEmailBody(body, NULL, 0, NULL, dir, rfc821Table, subtypeTable, options)) { |
|
536 | 536 |
messageReset(body); |
537 | 537 |
m = body; |
538 | 538 |
continue; |
... | ... |
@@ -581,7 +584,7 @@ cli_mbox(const char *dir, int desc) |
581 | 581 |
* Write out the last entry in the mailbox |
582 | 582 |
*/ |
583 | 583 |
if(messageGetBody(body)) |
584 |
- if(!parseEmailBody(body, NULL, 0, NULL, dir, rfc821Table, subtypeTable)) |
|
584 |
+ if(!parseEmailBody(body, NULL, 0, NULL, dir, rfc821Table, subtypeTable, options)) |
|
585 | 585 |
retcode = -1; |
586 | 586 |
|
587 | 587 |
/* |
... | ... |
@@ -749,7 +752,7 @@ parseEmailHeader(message *m, const char *line, const table_t *rfc821Table) |
749 | 749 |
* 2 for success, attachments not saved |
750 | 750 |
*/ |
751 | 751 |
static int /* success or fail */ |
752 |
-parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, const char *dir, table_t *rfc821Table, table_t *subtypeTable) |
|
752 |
+parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, const char *dir, table_t *rfc821Table, table_t *subtypeTable, unsigned int options) |
|
753 | 753 |
{ |
754 | 754 |
message **messages; /* parts of a multipart message */ |
755 | 755 |
int inhead, inMimeHead, i, rc = 1, htmltextPart, multiparts = 0; |
... | ... |
@@ -1081,7 +1084,7 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con |
1081 | 1081 |
cli_dbgmsg("No HTML code found to be scanned"); |
1082 | 1082 |
rc = 0; |
1083 | 1083 |
} else |
1084 |
- rc = parseEmailBody(aMessage, blobs, nBlobs, aText, dir, rfc821Table, subtypeTable); |
|
1084 |
+ rc = parseEmailBody(aMessage, blobs, nBlobs, aText, dir, rfc821Table, subtypeTable, options); |
|
1085 | 1085 |
blobArrayDestroy(blobs, nBlobs); |
1086 | 1086 |
blobs = NULL; |
1087 | 1087 |
nBlobs = 0; |
... | ... |
@@ -1121,7 +1124,7 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con |
1121 | 1121 |
aMessage = messages[htmltextPart]; |
1122 | 1122 |
aText = textAddMessage(aText, aMessage); |
1123 | 1123 |
|
1124 |
- rc = parseEmailBody(NULL, blobs, nBlobs, aText, dir, rfc821Table, subtypeTable); |
|
1124 |
+ rc = parseEmailBody(NULL, blobs, nBlobs, aText, dir, rfc821Table, subtypeTable, options); |
|
1125 | 1125 |
|
1126 | 1126 |
if(rc == 1) { |
1127 | 1127 |
/* |
... | ... |
@@ -1266,7 +1269,8 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con |
1266 | 1266 |
addAttachment = TRUE; |
1267 | 1267 |
} |
1268 | 1268 |
} else { |
1269 |
- checkURLs(aMessage, dir); |
|
1269 |
+ if(SCAN_MAILURL) |
|
1270 |
+ checkURLs(aMessage, dir); |
|
1270 | 1271 |
messageAddArgument(aMessage, "filename=textportion"); |
1271 | 1272 |
addAttachment = TRUE; |
1272 | 1273 |
} |
... | ... |
@@ -1315,7 +1319,7 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con |
1315 | 1315 |
messageDestroy(messages[i]); |
1316 | 1316 |
messages[i] = NULL; |
1317 | 1317 |
if(body) { |
1318 |
- rc = parseEmailBody(body, blobs, nBlobs, NULL, dir, rfc821Table, subtypeTable); |
|
1318 |
+ rc = parseEmailBody(body, blobs, nBlobs, NULL, dir, rfc821Table, subtypeTable, options); |
|
1319 | 1319 |
messageDestroy(body); |
1320 | 1320 |
} |
1321 | 1321 |
#endif |
... | ... |
@@ -1353,14 +1357,14 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con |
1353 | 1353 |
* The headers were parsed when reading in the |
1354 | 1354 |
* whole multipart section |
1355 | 1355 |
*/ |
1356 |
- rc = parseEmailBody(aMessage, blobs, nBlobs, aText, dir, rfc821Table, subtypeTable); |
|
1356 |
+ rc = parseEmailBody(aMessage, blobs, nBlobs, aText, dir, rfc821Table, subtypeTable, options); |
|
1357 | 1357 |
cli_dbgmsg("Finished recursion\n"); |
1358 | 1358 |
assert(aMessage == messages[i]); |
1359 | 1359 |
messageDestroy(messages[i]); |
1360 | 1360 |
messages[i] = NULL; |
1361 | 1361 |
#endif |
1362 | 1362 |
} else { |
1363 |
- rc = parseEmailBody(NULL, blobs, nBlobs, NULL, dir, rfc821Table, subtypeTable); |
|
1363 |
+ rc = parseEmailBody(NULL, blobs, nBlobs, NULL, dir, rfc821Table, subtypeTable, options); |
|
1364 | 1364 |
if(mainMessage && (mainMessage != messageIn)) |
1365 | 1365 |
messageDestroy(mainMessage); |
1366 | 1366 |
mainMessage = NULL; |
... | ... |
@@ -1415,7 +1419,7 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con |
1415 | 1415 |
|
1416 | 1416 |
if(numberOfAttachments == 0) { |
1417 | 1417 |
/* No usable attachment was found */ |
1418 |
- rc = parseEmailBody(NULL, NULL, 0, aText, dir, rfc821Table, subtypeTable); |
|
1418 |
+ rc = parseEmailBody(NULL, NULL, 0, aText, dir, rfc821Table, subtypeTable, options); |
|
1419 | 1419 |
break; |
1420 | 1420 |
} |
1421 | 1421 |
|
... | ... |
@@ -1453,7 +1457,7 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con |
1453 | 1453 |
* and quit - that's this part all done. |
1454 | 1454 |
*/ |
1455 | 1455 |
if(numberOfNewAttachments == 0) { |
1456 |
- rc = parseEmailBody(NULL, blobList, numberOfAttachments, NULL, dir, rfc821Table, subtypeTable); |
|
1456 |
+ rc = parseEmailBody(NULL, blobList, numberOfAttachments, NULL, dir, rfc821Table, subtypeTable, options); |
|
1457 | 1457 |
break; |
1458 | 1458 |
} |
1459 | 1459 |
/* |
... | ... |
@@ -1467,7 +1471,7 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con |
1467 | 1467 |
* infinite recursion |
1468 | 1468 |
*/ |
1469 | 1469 |
if(multiparts > 1) |
1470 |
- rc = parseEmailBody(mainMessage, blobList, numberOfAttachments, aText, dir, rfc821Table, subtypeTable); |
|
1470 |
+ rc = parseEmailBody(mainMessage, blobList, numberOfAttachments, aText, dir, rfc821Table, subtypeTable, options); |
|
1471 | 1471 |
else if(numberOfAttachments == 1) { |
1472 | 1472 |
(void)saveFile(blobList[0], dir); |
1473 | 1473 |
blobDestroy(blobList[0]); |
... | ... |
@@ -1494,7 +1498,7 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con |
1494 | 1494 |
if(htmltextPart == -1) |
1495 | 1495 |
htmltextPart = 0; |
1496 | 1496 |
|
1497 |
- rc = parseEmailBody(messages[htmltextPart], blobs, nBlobs, aText, dir, rfc821Table, subtypeTable); |
|
1497 |
+ rc = parseEmailBody(messages[htmltextPart], blobs, nBlobs, aText, dir, rfc821Table, subtypeTable, options); |
|
1498 | 1498 |
blobArrayDestroy(blobs, nBlobs); |
1499 | 1499 |
blobs = NULL; |
1500 | 1500 |
nBlobs = 0; |
... | ... |
@@ -1552,7 +1556,7 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con |
1552 | 1552 |
mainMessage = NULL; |
1553 | 1553 |
} |
1554 | 1554 |
if(messageGetBody(m)) |
1555 |
- rc = parseEmailBody(m, NULL, 0, NULL, dir, rfc821Table, subtypeTable); |
|
1555 |
+ rc = parseEmailBody(m, NULL, 0, NULL, dir, rfc821Table, subtypeTable, options); |
|
1556 | 1556 |
|
1557 | 1557 |
messageDestroy(m); |
1558 | 1558 |
} |
... | ... |
@@ -2201,7 +2205,6 @@ saveFile(const blob *b, const char *dir) |
2201 | 2201 |
return (close(fd) >= 0); |
2202 | 2202 |
} |
2203 | 2203 |
|
2204 |
-#ifdef CHECKURLS |
|
2205 | 2204 |
static void |
2206 | 2205 |
checkURLs(message *m, const char *dir) |
2207 | 2206 |
{ |
... | ... |
@@ -2278,13 +2281,6 @@ checkURLs(message *m, const char *dir) |
2278 | 2278 |
} |
2279 | 2279 |
blobDestroy(b); |
2280 | 2280 |
} |
2281 |
-#else |
|
2282 |
-static void |
|
2283 |
-checkURLs(message *m, const char *dir) |
|
2284 |
-{ |
|
2285 |
-} |
|
2286 |
-#endif |
|
2287 |
- |
|
2288 | 2281 |
|
2289 | 2282 |
#ifdef HAVE_BACKTRACE |
2290 | 2283 |
static void |
... | ... |
@@ -49,7 +49,7 @@ int cli_scanrar_inuse = 0; |
49 | 49 |
|
50 | 50 |
extern short cli_leavetemps_flag; |
51 | 51 |
|
52 |
-extern int cli_mbox(const char *dir, int desc); /* FIXME */ |
|
52 |
+extern int cli_mbox(const char *dir, int desc, unsigned int options); /* FIXME */ |
|
53 | 53 |
|
54 | 54 |
#include "clamav.h" |
55 | 55 |
#include "others.h" |
... | ... |
@@ -1006,7 +1006,7 @@ static int cli_scanmail(int desc, const char **virname, long int *scanned, const |
1006 | 1006 |
/* |
1007 | 1007 |
* Extract the attachments into the temporary directory |
1008 | 1008 |
*/ |
1009 |
- ret = cli_mbox(dir, desc); |
|
1009 |
+ ret = cli_mbox(dir, desc, options); |
|
1010 | 1010 |
/* FIXME: check mbox return code */ |
1011 | 1011 |
|
1012 | 1012 |
ret = cli_scandir(dir, virname, scanned, root, limits, options, arec, mrec); |