git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@186 77e5149b-7576-45b1-b177-96237e5ba77b
Nigel Horne authored on 2004/01/13 19:14:13... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Tue Jan 13 10:12:36 GMT 2004 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav: Remove duplicate code when handling multipart messages |
|
4 |
+ |
|
1 | 5 |
Mon Jan 12 15:31:32 GMT 2004 (njh) |
2 | 6 |
---------------------------------- |
3 | 7 |
* clamav-milter: FixStaleSocket: no longer complain if asked to remove |
... | ... |
@@ -28,12 +32,12 @@ Fri Jan 9 18:27:19 GMT 2004 (njh) |
28 | 28 |
Fri Jan 9 18:01:28 GMT 2004 (njh) |
29 | 29 |
---------------------------------- |
30 | 30 |
* libclamav: Started handling BinHex code. For now only works with |
31 |
- "inline" messages where the BinHex is in the main body of the plain |
|
31 |
+ "inline" messages where the BinHex is in the main body of the plain |
|
32 | 32 |
text portion. |
33 | 33 |
|
34 | 34 |
Fri Jan 9 15:08:01 GMT 2004 (njh) |
35 | 35 |
---------------------------------- |
36 |
- * libclamav: Re-engineered handling of |
|
36 |
+ * libclamav: Re-engineered handling of |
|
37 | 37 |
Handle Content-Type: /; name="eicar.com" |
38 | 38 |
which was lost in recent code change. Should now apply to more |
39 | 39 |
cases |
... | ... |
@@ -45,7 +49,7 @@ Fri Jan 9 14:46:29 GMT 2004 (njh) |
45 | 45 |
Fri Jan 9 10:21:27 GMT 2004 (njh) |
46 | 46 |
---------------------------------- |
47 | 47 |
* libclamav: Locate uuencoded viruses hidden in text poritions of |
48 |
- multipart/mixed mime messages |
|
48 |
+ multipart/mixed mime messages |
|
49 | 49 |
|
50 | 50 |
Fri Jan 9 02:07:53 CET 2004 (tk) |
51 | 51 |
--------------------------------- |
... | ... |
@@ -60,7 +64,7 @@ Wed Jan 7 21:50:28 CET 2004 (tk) |
60 | 60 |
Tue Jan 6 14:42:00 GMT 2004 (njh) |
61 | 61 |
---------------------------------- |
62 | 62 |
* libclamav: Handle headers which do not not have a space after the ':' |
63 |
- Example mail submitted by "Diego d'Ambra" <da@softcom.dk> |
|
63 |
+ Example mail submitted by "Diego d'Ambra" <da@softcom.dk> |
|
64 | 64 |
|
65 | 65 |
Tue Jan 6 14:43:42 CET 2004 (tk) |
66 | 66 |
--------------------------------- |
... | ... |
@@ -167,12 +171,12 @@ Fri Dec 12 13:43:50 GMT 2003 (njh) |
167 | 167 |
Thu Dec 11 14:36:32 GMT 2003 (njh) |
168 | 168 |
---------------------------------- |
169 | 169 |
* libclamav: better handling of encapsulated messages, i.e. emails |
170 |
- within other emails such as forwarded messages |
|
170 |
+ within other emails such as forwarded messages |
|
171 | 171 |
|
172 | 172 |
Wed Dec 10 12:01:27 GMT 2003 (njh) |
173 | 173 |
---------------------------------- |
174 | 174 |
* clamav-milter: Timeout on waiting for data from clamd, by honouring |
175 |
- ThreadTimeout in clamav.conf |
|
175 |
+ ThreadTimeout in clamav.conf |
|
176 | 176 |
|
177 | 177 |
Tue Dec 9 09:22:46 GMT 2003 (njh) |
178 | 178 |
---------------------------------- |
... | ... |
@@ -189,7 +193,7 @@ Sun Dec 7 22:46:15 CET 2003 (tk) |
189 | 189 |
Sat Dec 6 04:04:00 GMT 2003 (njh) |
190 | 190 |
---------------------------------- |
191 | 191 |
* libclamav: Handle hand crafted emails that incorrectly set multipart headers |
192 |
- Handcrafted examples sent by Michael Dankov <misha@btrc.ru> |
|
192 |
+ Handcrafted examples sent by Michael Dankov <misha@btrc.ru> |
|
193 | 193 |
|
194 | 194 |
Sat Dec 6 00:43:08 CET 2003 (tk) |
195 | 195 |
--------------------------------- |
... | ... |
@@ -322,7 +326,7 @@ Sat Nov 22 17:23:10 IST 2003 (njh) |
322 | 322 |
Fri Nov 21 12:58:02 IST 2003 (njh) |
323 | 323 |
--------------------------------- |
324 | 324 |
* libclamav: Scan multipart alternatives that have no boundaries, finds some |
325 |
- uuencoded happy99 |
|
325 |
+ uuencoded happy99 |
|
326 | 326 |
|
327 | 327 |
Wed Nov 19 16:34:04 GMT 2003 (njh) |
328 | 328 |
--------------------------------- |
... | ... |
@@ -386,7 +390,7 @@ Tue Nov 11 13:51:23 IST 2003 (njh) |
386 | 386 |
---------------------------------- |
387 | 387 |
* clamav-milter: Fixed handling of % characters in e-mail addresses |
388 | 388 |
pointed out by dotslash@snosoft.com |
389 |
- |
|
389 |
+ |
|
390 | 390 |
Sun Nov 9 20:25:11 CET 2003 (tk) |
391 | 391 |
--------------------------------- |
392 | 392 |
* libclamav: some functions were still using SCANBUFF instead of FILEBUFF, |
... | ... |
@@ -436,7 +440,7 @@ Wed Nov 5 11:35:22 CET 2003 (tk) |
436 | 436 |
Wed Nov 5 12:34:34 IST 2003 (njh) |
437 | 437 |
---------------------------------- |
438 | 438 |
* libclamav: Handle spam that sends broken content-disposition |
439 |
- (Fix by NJH, Bug notified by Laurent Wacrenier <lwa@teaser.fr>) |
|
439 |
+ (Fix by NJH, Bug notified by Laurent Wacrenier <lwa@teaser.fr>) |
|
440 | 440 |
|
441 | 441 |
Wed Nov 5 01:52:03 CET 2003 (tk) |
442 | 442 |
--------------------------------- |
... | ... |
@@ -450,7 +454,7 @@ Tue Nov 4 13:37:21 CET 2003 (tk) |
450 | 450 |
Tue Nov 4 08:27:00 GMT 2003 (njh) |
451 | 451 |
---------------------------------- |
452 | 452 |
* libclamav: Handle multipart messages that have no text portion |
453 |
- (Fix by NJH, Bug notified by Laurent Wacrenier <lwa@teaser.fr>) |
|
453 |
+ (Fix by NJH, Bug notified by Laurent Wacrenier <lwa@teaser.fr>) |
|
454 | 454 |
|
455 | 455 |
Tue Nov 4 00:37:03 CET 2003 (tk) |
456 | 456 |
--------------------------------- |
... | ... |
@@ -523,7 +527,7 @@ Fri Oct 17 05:08:22 CEST 2003 (tk) |
523 | 523 |
Sun Oct 12 21:14:21 BST 2003 (njh) |
524 | 524 |
--------------------------------- |
525 | 525 |
* libclamav: mbox.c now uses NO_STRTOK_R consistently with message.c |
526 |
- Patch by Bernd Kuhls <spiralvoice@hotmail.com> |
|
526 |
+ Patch by Bernd Kuhls <spiralvoice@hotmail.com> |
|
527 | 527 |
|
528 | 528 |
Sun Oct 12 19:46:18 CEST 2003 (tk) |
529 | 529 |
---------------------------------- |
... | ... |
@@ -532,15 +536,15 @@ Sun Oct 12 19:46:18 CEST 2003 (tk) |
532 | 532 |
Sun Oct 12 09:37:44 BST 2003 (njh) |
533 | 533 |
--------------------------------- |
534 | 534 |
* libclamav: handles Eicar found in Appledouble files, though Appledouble |
535 |
- files are not yet handled |
|
535 |
+ files are not yet handled |
|
536 | 536 |
* clamav-milter: use VERSION info to talk to clamd not PING/PONG |
537 |
- Only close fd 0/1/2 if !Foreground |
|
537 |
+ Only close fd 0/1/2 if !Foreground |
|
538 | 538 |
Sanity checking now performed on LocalSocket as well as TCPSocket |
539 | 539 |
|
540 | 540 |
Sat Oct 11 16:42:42 BST 2003 (njh) |
541 | 541 |
--------------------------------- |
542 | 542 |
* clamav-milter: fixed possible crash with long e-mail addresses |
543 |
- Removed call to clamdscan to get version |
|
543 |
+ Removed call to clamdscan to get version |
|
544 | 544 |
|
545 | 545 |
Thu Oct 9 15:18:44 CEST 2003 (tk) |
546 | 546 |
---------------------------------- |
... | ... |
@@ -558,7 +562,7 @@ Wed Oct 8 12:39:26 CEST 2003 (tk) |
558 | 558 |
Sun Oct 5 18:30:40 BST 2003 (njh) |
559 | 559 |
---------------------------------- |
560 | 560 |
* clamav-milter: Used to always remove old UNIX domain sockets, now |
561 |
- only does that if FixStaleSocket is set |
|
561 |
+ only does that if FixStaleSocket is set |
|
562 | 562 |
|
563 | 563 |
Sun Oct 5 14:58:05 BST 2003 (njh) |
564 | 564 |
---------------------------------- |
... | ... |
@@ -579,7 +583,7 @@ Thu Oct 2 19:43:57 CEST 2003 (tk) |
579 | 579 |
Wed Oct 1 10:52:35 BST 2003 (njh) |
580 | 580 |
---------------------------------- |
581 | 581 |
* libclamav: mbox/message now handles content type definition on a new |
582 |
- line |
|
582 |
+ line |
|
583 | 583 |
|
584 | 584 |
Tue Sep 30 12:54:32 BST 2003 (njh) |
585 | 585 |
---------------------------------- |
... | ... |
@@ -613,12 +617,12 @@ Mon Sep 29 13:42:51 CEST 2003 (tk) |
613 | 613 |
Mon Sep 29 07:15:30 BST 2003 (njh) |
614 | 614 |
---------------------------------- |
615 | 615 |
* clamav-milter: ensure remoteIP is initialised |
616 |
- max-children now overrides MaxThreads |
|
616 |
+ max-children now overrides MaxThreads |
|
617 | 617 |
|
618 | 618 |
Sun Sep 28 17:38:44 BST 2003 (njh) |
619 | 619 |
---------------------------------- |
620 | 620 |
* clamav-milter: added --force-scan flag |
621 |
- Use MaxThreads if --max-children not set |
|
621 |
+ Use MaxThreads if --max-children not set |
|
622 | 622 |
(thanks to "Richard G. Roberto" <rgr@dedlegend.com>) |
623 | 623 |
|
624 | 624 |
Sun Sep 28 11:07:49 BST 2003 (njh) |
... | ... |
@@ -639,7 +643,7 @@ Wed Sep 24 10:37:10 BST 2003 (njh) |
639 | 639 |
---------------------------------- |
640 | 640 |
|
641 | 641 |
* libclamav: fixed core dump when the plain text file contained just |
642 |
- the text "begin <number>" |
|
642 |
+ the text "begin <number>" |
|
643 | 643 |
|
644 | 644 |
Wed Sep 24 06:54:56 BST 2003 (njh) |
645 | 645 |
--------------------------------- |
... | ... |
@@ -677,7 +681,7 @@ Tue Sep 16 18:06:47 CEST 2003 (tk) |
677 | 677 |
Mon Sep 15 14:09:50 BST 2003 |
678 | 678 |
---------------------------- |
679 | 679 |
* libclamav/mbox.c: Fixed potential buffer overrun files with long names |
680 |
- DOS style filename suffixes |
|
680 |
+ DOS style filename suffixes |
|
681 | 681 |
|
682 | 682 |
Mon Sep 15 13:23:27 BST 2003 |
683 | 683 |
--------------------------- |
... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: mbox.c,v $ |
20 |
+ * Revision 1.30 2004/01/13 10:12:05 nigelhorne |
|
21 |
+ * Remove duplicate code when handling multipart messages |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.29 2004/01/09 18:27:11 nigelhorne |
21 | 24 |
* ParseMimeHeader could corrupt arg |
22 | 25 |
* |
... | ... |
@@ -78,7 +81,7 @@ |
78 | 78 |
* Compilable under SCO; removed duplicate code with message.c |
79 | 79 |
* |
80 | 80 |
*/ |
81 |
-static char const rcsid[] = "$Id: mbox.c,v 1.29 2004/01/09 18:27:11 nigelhorne Exp $"; |
|
81 |
+static char const rcsid[] = "$Id: mbox.c,v 1.30 2004/01/13 10:12:05 nigelhorne Exp $"; |
|
82 | 82 |
|
83 | 83 |
#ifndef CL_DEBUG |
84 | 84 |
/*#define NDEBUG /* map CLAMAV debug onto standard */ |
... | ... |
@@ -131,6 +134,7 @@ static char const rcsid[] = "$Id: mbox.c,v 1.29 2004/01/09 18:27:11 nigelhorne E |
131 | 131 |
typedef enum { FALSE = 0, TRUE = 1 } bool; |
132 | 132 |
|
133 | 133 |
static message *parseEmailHeaders(const message *m, const table_t *rfc821Table); |
134 |
+static int parseEmailHeader(message *m, const char *line, const table_t *rfc821Table); |
|
134 | 135 |
static int parseEmailBody(message *mainMessage, blob **blobsIn, int nBlobs, text *textIn, const char *dir, table_t *rfc821Table, table_t *subtypeTable); |
135 | 136 |
static int boundaryStart(const char *line, const char *boundary); |
136 | 137 |
static int endOfMessage(const char *line, const char *boundary); |
... | ... |
@@ -388,44 +392,9 @@ parseEmailHeaders(const message *m, const table_t *rfc821Table) |
388 | 388 |
if(strstrip(buffer) == 0) { |
389 | 389 |
cli_dbgmsg("End of header information\n"); |
390 | 390 |
inHeader = FALSE; |
391 |
- } else { |
|
392 |
- const bool isLastLine = !continuationMarker(buffer); |
|
393 |
- char *cmd = strtok_r(buffer, " \t", &strptr); |
|
394 |
- |
|
395 |
- if(*cmd) { |
|
396 |
- char *arg = strtok_r(NULL, "", &strptr); |
|
391 |
+ } else if(parseEmailHeader(ret, buffer, rfc821Table) == CONTENT_TYPE) |
|
392 |
+ inContinuationHeader = continuationMarker(buffer); |
|
397 | 393 |
|
398 |
- if(arg) { |
|
399 |
- /* |
|
400 |
- * Found a header such as |
|
401 |
- * Content-Type: multipart/mixed; |
|
402 |
- * set arg to be |
|
403 |
- * "multipart/mixed" and cmd to |
|
404 |
- * be "Content-Type:" |
|
405 |
- */ |
|
406 |
- if(parseMimeHeader(ret, cmd, rfc821Table, arg) == CONTENT_TYPE) |
|
407 |
- inContinuationHeader = !isLastLine; |
|
408 |
- } else { |
|
409 |
- /* |
|
410 |
- * Handle the case where the |
|
411 |
- * header does not have a space |
|
412 |
- * after the ':', e.g. |
|
413 |
- * Content-Type:multipart/mixed; |
|
414 |
- */ |
|
415 |
- arg = strchr(cmd, ':'); |
|
416 |
- if(arg && (*++arg != '\0')) { |
|
417 |
- char *p; |
|
418 |
- |
|
419 |
- cmd = strdup(cmd); |
|
420 |
- p = strchr(cmd, ':'); |
|
421 |
- *++p = '\0'; |
|
422 |
- if(parseMimeHeader(ret, cmd, rfc821Table, arg) == CONTENT_TYPE) |
|
423 |
- inContinuationHeader = !isLastLine; |
|
424 |
- free(cmd); |
|
425 |
- } |
|
426 |
- } |
|
427 |
- } |
|
428 |
- } |
|
429 | 394 |
} else |
430 | 395 |
messageAddLine(ret, buffer); |
431 | 396 |
free(buffer); |
... | ... |
@@ -437,6 +406,58 @@ parseEmailHeaders(const message *m, const table_t *rfc821Table) |
437 | 437 |
} |
438 | 438 |
|
439 | 439 |
/* |
440 |
+ * Handle a header line of an email message |
|
441 |
+ * TODO: handle spaces before the ':' |
|
442 |
+ */ |
|
443 |
+static int |
|
444 |
+parseEmailHeader(message *m, const char *line, const table_t *rfc821Table) |
|
445 |
+{ |
|
446 |
+ char *copy = strdup(line); |
|
447 |
+ char *cmd; |
|
448 |
+ int ret = -1; |
|
449 |
+#ifdef CL_THREAD_SAFE |
|
450 |
+ char *strptr; |
|
451 |
+#endif |
|
452 |
+ |
|
453 |
+ cmd = strtok_r(copy, " \t", &strptr); |
|
454 |
+ |
|
455 |
+ if(*cmd) { |
|
456 |
+ char *arg = strtok_r(NULL, "", &strptr); |
|
457 |
+ |
|
458 |
+ if(arg) |
|
459 |
+ /* |
|
460 |
+ * Found a header such as |
|
461 |
+ * Content-Type: multipart/mixed; |
|
462 |
+ * set arg to be |
|
463 |
+ * "multipart/mixed" and cmd to |
|
464 |
+ * be "Content-Type:" |
|
465 |
+ */ |
|
466 |
+ ret = parseMimeHeader(m, cmd, rfc821Table, arg); |
|
467 |
+ else { |
|
468 |
+ /* |
|
469 |
+ * Handle the case where the |
|
470 |
+ * header does not have a space |
|
471 |
+ * after the ':', e.g. |
|
472 |
+ * Content-Type:multipart/mixed; |
|
473 |
+ */ |
|
474 |
+ arg = strchr(cmd, ':'); |
|
475 |
+ if(arg && (*++arg != '\0')) { |
|
476 |
+ char *p; |
|
477 |
+ |
|
478 |
+ cmd = strdup(cmd); |
|
479 |
+ p = strchr(cmd, ':'); |
|
480 |
+ *++p = '\0'; |
|
481 |
+ ret = parseMimeHeader(m, cmd, rfc821Table, arg); |
|
482 |
+ free(cmd); |
|
483 |
+ } |
|
484 |
+ } |
|
485 |
+ } |
|
486 |
+ free(copy); |
|
487 |
+ |
|
488 |
+ return ret; |
|
489 |
+} |
|
490 |
+ |
|
491 |
+/* |
|
440 | 492 |
* This is a recursive routine. |
441 | 493 |
* |
442 | 494 |
* This function parses the body of mainMessage and saves its attachments in dir |
... | ... |
@@ -482,9 +503,6 @@ parseEmailBody(message *mainMessage, blob **blobsIn, int nBlobs, text *textIn, c |
482 | 482 |
/*bool isAlternative;*/ |
483 | 483 |
const char *boundary; |
484 | 484 |
message *aMessage; |
485 |
-#ifdef CL_THREAD_SAFE |
|
486 |
- char *strptr; |
|
487 |
-#endif |
|
488 | 485 |
|
489 | 486 |
cli_dbgmsg("Parsing mail file\n"); |
490 | 487 |
|
... | ... |
@@ -590,8 +608,6 @@ parseEmailBody(message *mainMessage, blob **blobsIn, int nBlobs, text *textIn, c |
590 | 590 |
inMimeHead = continuationMarker(line); |
591 | 591 |
messageAddArgument(aMessage, line); |
592 | 592 |
} else if(inhead) { |
593 |
- char *copy, *cmd; |
|
594 |
- |
|
595 | 593 |
if(strlen(line) == 0) { |
596 | 594 |
inhead = 0; |
597 | 595 |
continue; |
... | ... |
@@ -605,47 +621,7 @@ parseEmailBody(message *mainMessage, blob **blobsIn, int nBlobs, text *textIn, c |
605 | 605 |
if(t_line->t_next && ((t_line->t_next->t_text[0] == '\t') || (t_line->t_next->t_text[0] == ' '))) |
606 | 606 |
inMimeHead = TRUE; |
607 | 607 |
|
608 |
- copy = strdup(line); |
|
609 |
- |
|
610 |
- cmd = strtok_r(copy, " \t", &strptr); |
|
611 |
- |
|
612 |
- /* |
|
613 |
- * TODO: duplication of code in |
|
614 |
- * parseEmailHeaders |
|
615 |
- */ |
|
616 |
- if(*cmd) { |
|
617 |
- char *arg = strtok_r(NULL, "", &strptr); |
|
618 |
- |
|
619 |
- if(arg) |
|
620 |
- /* |
|
621 |
- * Found a header such as |
|
622 |
- * Content-Type: multipart/mixed; |
|
623 |
- * set arg to be |
|
624 |
- * "multipart/mixed" and cmd to |
|
625 |
- * be "Content-Type:" |
|
626 |
- */ |
|
627 |
- parseMimeHeader(aMessage, cmd, rfc821Table, arg); |
|
628 |
- else { |
|
629 |
- /* |
|
630 |
- * Handle the case where the |
|
631 |
- * header does not have a space |
|
632 |
- * after the ':', e.g. |
|
633 |
- * Content-Type:multipart/mixed; |
|
634 |
- */ |
|
635 |
- arg = strchr(cmd, ':'); |
|
636 |
- if(arg && (*++arg != '\0')) { |
|
637 |
- char *p; |
|
638 |
- |
|
639 |
- cmd = strdup(cmd); |
|
640 |
- p = strchr(cmd, ':'); |
|
641 |
- *++p = '\0'; |
|
642 |
- parseMimeHeader(aMessage, cmd, rfc821Table, arg); |
|
643 |
- free(cmd); |
|
644 |
- } |
|
645 |
- } |
|
646 |
- } |
|
647 |
- |
|
648 |
- free(copy); |
|
608 |
+ parseEmailHeader(aMessage, line, rfc821Table); |
|
649 | 609 |
} else if(boundaryStart(line, boundary)) { |
650 | 610 |
inhead = 1; |
651 | 611 |
break; |