Allow any number of alternatives in multipart messages

git-svn: trunk@616
remotes/push_mirror/metadata
Nigel Horne 21 years ago
parent 456edb5589
commit b726511fbb
  1. 5
      clamav-devel/ChangeLog
  2. 25
      clamav-devel/libclamav/mbox.c
  3. 2
      clamav-devel/libclamav/mbox.h

@ -1,3 +1,8 @@
Fri Jun 18 11:08:26 BST 2004 (njh)
----------------------------------
* libclamav: Allow any number of alternatives in
multipart messages
Wed Jun 16 09:09:45 BST 2004 (njh) Wed Jun 16 09:09:45 BST 2004 (njh)
---------------------------------- ----------------------------------
* clamav-milter: Added access to sendmail variables in template * clamav-milter: Added access to sendmail variables in template

@ -17,6 +17,9 @@
* *
* Change History: * Change History:
* $Log: mbox.c,v $ * $Log: mbox.c,v $
* Revision 1.77 2004/06/18 10:07:12 nigelhorne
* Allow any number of alternatives in multipart messages
*
* Revision 1.76 2004/06/16 08:07:39 nigelhorne * Revision 1.76 2004/06/16 08:07:39 nigelhorne
* Added thread safety * Added thread safety
* *
@ -216,7 +219,7 @@
* Compilable under SCO; removed duplicate code with message.c * Compilable under SCO; removed duplicate code with message.c
* *
*/ */
static char const rcsid[] = "$Id: mbox.c,v 1.76 2004/06/16 08:07:39 nigelhorne Exp $"; static char const rcsid[] = "$Id: mbox.c,v 1.77 2004/06/18 10:07:12 nigelhorne Exp $";
#if HAVE_CONFIG_H #if HAVE_CONFIG_H
#include "clamav-config.h" #include "clamav-config.h"
@ -651,7 +654,7 @@ parseEmailHeader(message *m, const char *line, const table_t *rfc821Table)
static int /* success or fail */ static int /* success or fail */
parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, const char *dir, table_t *rfc821Table, table_t *subtypeTable) parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, const char *dir, table_t *rfc821Table, table_t *subtypeTable)
{ {
message *messages[MAXALTERNATIVE]; message **messages; /* parts of a multipart message */
int inhead, inMimeHead, i, rc = 1, htmltextPart, multiparts = 0; int inhead, inMimeHead, i, rc = 1, htmltextPart, multiparts = 0;
text *aText; text *aText;
blob *blobList[MAX_ATTACHMENTS], **blobs; blob *blobList[MAX_ATTACHMENTS], **blobs;
@ -668,6 +671,7 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con
aText = textIn; aText = textIn;
blobs = blobsIn; blobs = blobsIn;
messages = NULL;
mainMessage = messageIn; mainMessage = messageIn;
/* Anything left to be parsed? */ /* Anything left to be parsed? */
@ -767,9 +771,11 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con
* This looks like parseEmailHeaders() - maybe there's * This looks like parseEmailHeaders() - maybe there's
* some duplication of code to be cleaned up * some duplication of code to be cleaned up
*/ */
for(multiparts = 0; t_line && (multiparts < MAXALTERNATIVE); multiparts++) { for(multiparts = 0; t_line; multiparts++) {
int lines = 0; int lines = 0;
messages = cli_realloc(messages, ((multiparts + 1) * sizeof(message *)));
aMessage = messages[multiparts] = messageCreate(); aMessage = messages[multiparts] = messageCreate();
cli_dbgmsg("Now read in part %d\n", multiparts); cli_dbgmsg("Now read in part %d\n", multiparts);
@ -903,8 +909,11 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con
mainMessage = NULL; mainMessage = NULL;
} }
if(multiparts == 0) if(multiparts == 0) {
if(messages)
free(messages);
return 2; /* Nothing to do */ return 2; /* Nothing to do */
}
cli_dbgmsg("The message has %d parts\n", multiparts); cli_dbgmsg("The message has %d parts\n", multiparts);
cli_dbgmsg("Find out the multipart type(%s)\n", mimeSubtype); cli_dbgmsg("Find out the multipart type(%s)\n", mimeSubtype);
@ -1358,6 +1367,9 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con
if(aText && (textIn == NULL)) if(aText && (textIn == NULL))
textDestroy(aText); textDestroy(aText);
if(messages)
free(messages);
return rc; return rc;
case MESSAGE: case MESSAGE:
@ -1404,6 +1416,8 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con
if(mainMessage && (mainMessage != messageIn)) if(mainMessage && (mainMessage != messageIn))
messageDestroy(mainMessage); messageDestroy(mainMessage);
if(messages)
free(messages);
return 0; return 0;
case APPLICATION: case APPLICATION:
@ -1598,6 +1612,9 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con
if(mainMessage && (mainMessage != messageIn)) if(mainMessage && (mainMessage != messageIn))
messageDestroy(mainMessage); messageDestroy(mainMessage);
if(messages)
free(messages);
cli_dbgmsg("parseEmailBody() returning %d\n", rc); cli_dbgmsg("parseEmailBody() returning %d\n", rc);
return rc; return rc;

@ -25,8 +25,6 @@ typedef enum {
NOENCODING, QUOTEDPRINTABLE, BASE64, EIGHTBIT, BINARY, UUENCODE, EEXTENSION NOENCODING, QUOTEDPRINTABLE, BASE64, EIGHTBIT, BINARY, UUENCODE, EEXTENSION
} encoding_type; } encoding_type;
#define MAXALTERNATIVE 5 /* The maximum number of alternatives allowed in a message */
/* tk: shut up manager.c warning */ /* tk: shut up manager.c warning */
#include <clamav.h> #include <clamav.h>

Loading…
Cancel
Save