git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@1232 77e5149b-7576-45b1-b177-96237e5ba77b
Nigel Horne authored on 2005/01/07 08:25:18... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Thu Jan 6 23:24:35 GMT 2005 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav/mbox.c: Better handler of single quotes in headers |
|
4 |
+ |
|
1 | 5 |
Thu Jan 6 11:54:54 GMT 2005 (njh) |
2 | 6 |
---------------------------------- |
3 | 7 |
* libclamav/mbox.c: Scan for bounces in non mime-encoded emails |
... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: mbox.c,v $ |
20 |
+ * Revision 1.207 2005/01/06 23:21:34 nigelhorne |
|
21 |
+ * Improved handling of quotes over multiple lines in headers |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.206 2005/01/06 11:53:29 nigelhorne |
21 | 24 |
* Handle bounces in non mime encoded messages |
22 | 25 |
* |
... | ... |
@@ -606,7 +609,7 @@ |
606 | 606 |
* Compilable under SCO; removed duplicate code with message.c |
607 | 607 |
* |
608 | 608 |
*/ |
609 |
-static char const rcsid[] = "$Id: mbox.c,v 1.206 2005/01/06 11:53:29 nigelhorne Exp $"; |
|
609 |
+static char const rcsid[] = "$Id: mbox.c,v 1.207 2005/01/06 23:21:34 nigelhorne Exp $"; |
|
610 | 610 |
|
611 | 611 |
#if HAVE_CONFIG_H |
612 | 612 |
#include "clamav-config.h" |
... | ... |
@@ -1431,8 +1434,9 @@ parseEmailFile(FILE *fin, const table_t *rfc821, const char *firstLine) |
1431 | 1431 |
* otherwise they'll be treated as the end of header marker |
1432 | 1432 |
*/ |
1433 | 1433 |
if(inHeader) { |
1434 |
- cli_dbgmsg("parseEmailFile: check '%s'\n", start ? start : ""); |
|
1435 |
- if(start == NULL) { /* empty line */ |
|
1434 |
+ cli_dbgmsg("parseEmailFile: check '%s' contMarker %d\n", |
|
1435 |
+ buffer ? buffer : "", (int)contMarker); |
|
1436 |
+ if((start == NULL) && (fullline == NULL)) { /* empty line */ |
|
1436 | 1437 |
if(!contMarker) { |
1437 | 1438 |
/* |
1438 | 1439 |
* A blank line signifies the end of |
... | ... |
@@ -1445,7 +1449,7 @@ parseEmailFile(FILE *fin, const table_t *rfc821, const char *firstLine) |
1445 | 1445 |
} else { |
1446 | 1446 |
char *ptr; |
1447 | 1447 |
const char *qptr; |
1448 |
- int quotes, lookahead; |
|
1448 |
+ int lookahead; |
|
1449 | 1449 |
|
1450 | 1450 |
if(fullline == NULL) { |
1451 | 1451 |
char cmd[LINE_LENGTH + 1]; |
... | ... |
@@ -1492,10 +1496,13 @@ parseEmailFile(FILE *fin, const table_t *rfc821, const char *firstLine) |
1492 | 1492 |
strcat(fullline, start); |
1493 | 1493 |
} |
1494 | 1494 |
|
1495 |
- contMarker = continuationMarker(start); |
|
1495 |
+ if(start) { |
|
1496 |
+ contMarker = continuationMarker(start); |
|
1496 | 1497 |
|
1497 |
- if(contMarker) |
|
1498 |
- continue; |
|
1498 |
+ if(contMarker) |
|
1499 |
+ continue; |
|
1500 |
+ } else |
|
1501 |
+ contMarker = FALSE; |
|
1499 | 1502 |
|
1500 | 1503 |
assert(fullline != NULL); |
1501 | 1504 |
|
... | ... |
@@ -1514,13 +1521,15 @@ parseEmailFile(FILE *fin, const table_t *rfc821, const char *firstLine) |
1514 | 1514 |
continue; |
1515 | 1515 |
} |
1516 | 1516 |
|
1517 |
- quotes = 0; |
|
1518 |
- for(qptr = start; *qptr; qptr++) |
|
1519 |
- if(*qptr == '\"') |
|
1520 |
- quotes++; |
|
1517 |
+ if(start) { |
|
1518 |
+ int quotes = 0; |
|
1519 |
+ for(qptr = fullline; *qptr; qptr++) |
|
1520 |
+ if(*qptr == '\"') |
|
1521 |
+ quotes++; |
|
1521 | 1522 |
|
1522 |
- if(quotes & 1) |
|
1523 |
- continue; |
|
1523 |
+ if(quotes & 1) |
|
1524 |
+ continue; |
|
1525 |
+ } |
|
1524 | 1526 |
|
1525 | 1527 |
ptr = rfc822comments(fullline); |
1526 | 1528 |
if(ptr) { |
... | ... |
@@ -1545,7 +1554,7 @@ parseEmailFile(FILE *fin, const table_t *rfc821, const char *firstLine) |
1545 | 1545 |
case CONTENT_TRANSFER_ENCODING: |
1546 | 1546 |
case CONTENT_DISPOSITION: |
1547 | 1547 |
case CONTENT_TYPE: |
1548 |
- cli_warnmsg("parseEmailHeaders: Fullline set '%s' - report to bugs@clamav.net\n", fullline); |
|
1548 |
+ cli_warnmsg("parseEmailFile: Fullline set '%s' - report to bugs@clamav.net\n", fullline); |
|
1549 | 1549 |
} |
1550 | 1550 |
free(fullline); |
1551 | 1551 |
} |
... | ... |
@@ -1606,7 +1615,8 @@ parseEmailHeaders(const message *m, const table_t *rfc821) |
1606 | 1606 |
buffer = NULL; |
1607 | 1607 |
|
1608 | 1608 |
if(inHeader) { |
1609 |
- cli_dbgmsg("parseEmailHeaders: check '%s'\n", buffer ? buffer : ""); |
|
1609 |
+ cli_dbgmsg("parseEmailHeaders: check '%s' contMarker %d\n", |
|
1610 |
+ buffer ? buffer : "", (int)contMarker); |
|
1610 | 1611 |
if(buffer == NULL) { |
1611 | 1612 |
if(!contMarker) { |
1612 | 1613 |
/* |
... | ... |
@@ -1689,7 +1699,7 @@ parseEmailHeaders(const message *m, const table_t *rfc821) |
1689 | 1689 |
} |
1690 | 1690 |
|
1691 | 1691 |
quotes = 0; |
1692 |
- for(qptr = buffer; *qptr; qptr++) |
|
1692 |
+ for(qptr = fullline; *qptr; qptr++) |
|
1693 | 1693 |
if(*qptr == '\"') |
1694 | 1694 |
quotes++; |
1695 | 1695 |
|