git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@911 77e5149b-7576-45b1-b177-96237e5ba77b
Nigel Horne authored on 2004/09/21 02:09:25... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: mbox.c,v $ |
20 |
+ * Revision 1.134 2004/09/20 17:08:43 nigelhorne |
|
21 |
+ * Some performance enhancements |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.133 2004/09/20 12:44:03 nigelhorne |
21 | 24 |
* Fix parsing error on mime arguments |
22 | 25 |
* |
... | ... |
@@ -387,7 +390,7 @@ |
387 | 387 |
* Compilable under SCO; removed duplicate code with message.c |
388 | 388 |
* |
389 | 389 |
*/ |
390 |
-static char const rcsid[] = "$Id: mbox.c,v 1.133 2004/09/20 12:44:03 nigelhorne Exp $"; |
|
390 |
+static char const rcsid[] = "$Id: mbox.c,v 1.134 2004/09/20 17:08:43 nigelhorne Exp $"; |
|
391 | 391 |
|
392 | 392 |
#if HAVE_CONFIG_H |
393 | 393 |
#include "clamav-config.h" |
... | ... |
@@ -1321,11 +1324,16 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t |
1321 | 1321 |
break; |
1322 | 1322 |
} |
1323 | 1323 |
|
1324 |
- if(htmltextPart == -1) { |
|
1324 |
+ if(htmltextPart == -1) |
|
1325 | 1325 |
cli_dbgmsg("No HTML code found to be scanned"); |
1326 |
- rc = 0; |
|
1327 |
- } else |
|
1326 |
+ else { |
|
1328 | 1327 |
rc = parseEmailBody(aMessage, aText, dir, rfc821Table, subtypeTable, options); |
1328 |
+ if(rc == 1) { |
|
1329 |
+ assert(aMessage == messages[htmltextPart]); |
|
1330 |
+ messageDestroy(aMessage); |
|
1331 |
+ messages[htmltextPart] = NULL; |
|
1332 |
+ } |
|
1333 |
+ } |
|
1329 | 1334 |
|
1330 | 1335 |
/* |
1331 | 1336 |
* Fixed based on an idea from Stephen White <stephen@earth.li> |
... | ... |
@@ -1354,6 +1362,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t |
1354 | 1354 |
case ALTERNATIVE: |
1355 | 1355 |
cli_dbgmsg("Multipart alternative handler\n"); |
1356 | 1356 |
|
1357 |
+#if 0 |
|
1357 | 1358 |
htmltextPart = getTextPart(messages, multiparts); |
1358 | 1359 |
|
1359 | 1360 |
if(htmltextPart == -1) |
... | ... |
@@ -1371,6 +1380,8 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t |
1371 | 1371 |
* the same thing |
1372 | 1372 |
*/ |
1373 | 1373 |
rc = 2; |
1374 |
+#endif |
|
1375 |
+ |
|
1374 | 1376 |
/* |
1375 | 1377 |
* Fall through - some clients are broken and |
1376 | 1378 |
* say alternative instead of mixed. The Klez |
... | ... |
@@ -1411,7 +1422,8 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t |
1411 | 1411 |
|
1412 | 1412 |
aMessage = messages[i]; |
1413 | 1413 |
|
1414 |
- assert(aMessage != NULL); |
|
1414 |
+ if(aMessage == NULL) |
|
1415 |
+ continue; |
|
1415 | 1416 |
|
1416 | 1417 |
dtype = messageGetDispositionType(aMessage); |
1417 | 1418 |
cptr = messageGetMimeSubtype(aMessage); |
... | ... |
@@ -1683,7 +1695,8 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t |
1683 | 1683 |
if(mainMessage && (mainMessage != messageIn)) { |
1684 | 1684 |
messageDestroy(mainMessage); |
1685 | 1685 |
mainMessage = NULL; |
1686 |
- } |
|
1686 |
+ } else |
|
1687 |
+ messageReset(mainMessage); |
|
1687 | 1688 |
if(messageGetBody(m)) |
1688 | 1689 |
rc = parseEmailBody(m, NULL, dir, rfc821Table, subtypeTable, options); |
1689 | 1690 |
|
... | ... |
@@ -1845,13 +1858,15 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t |
1845 | 1845 |
fileblobDestroy(fb); |
1846 | 1846 |
} |
1847 | 1847 |
saveIt = FALSE; |
1848 |
- } else |
|
1848 |
+ } else if(multiparts == 0) |
|
1849 | 1849 |
/* |
1850 | 1850 |
* Save the entire text portion, |
1851 | 1851 |
* since it it may be an HTML file with |
1852 | 1852 |
* a JavaScript virus |
1853 | 1853 |
*/ |
1854 | 1854 |
saveIt = TRUE; |
1855 |
+ else |
|
1856 |
+ saveIt = FALSE; |
|
1855 | 1857 |
|
1856 | 1858 |
if(saveIt) { |
1857 | 1859 |
cli_dbgmsg("Saving text part to scan\n"); |
... | ... |
@@ -1859,6 +1874,12 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t |
1859 | 1859 |
* TODO: May be better to save aText |
1860 | 1860 |
*/ |
1861 | 1861 |
saveTextPart(mainMessage, dir); |
1862 |
+ if(mainMessage != messageIn) { |
|
1863 |
+ messageDestroy(mainMessage); |
|
1864 |
+ mainMessage = NULL; |
|
1865 |
+ } else |
|
1866 |
+ messageReset(mainMessage); |
|
1867 |
+ rc = 1; |
|
1862 | 1868 |
} |
1863 | 1869 |
} |
1864 | 1870 |
} else |