From b726511fbbad2d7beac8c0a6e7e6def763f98944 Mon Sep 17 00:00:00 2001 From: Nigel Horne Date: Fri, 18 Jun 2004 10:09:33 +0000 Subject: [PATCH] Allow any number of alternatives in multipart messages git-svn: trunk@616 --- clamav-devel/ChangeLog | 5 +++++ clamav-devel/libclamav/mbox.c | 25 +++++++++++++++++++++---- clamav-devel/libclamav/mbox.h | 2 -- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/clamav-devel/ChangeLog b/clamav-devel/ChangeLog index 967d78cc0..c72ec692b 100644 --- a/clamav-devel/ChangeLog +++ b/clamav-devel/ChangeLog @@ -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) ---------------------------------- * clamav-milter: Added access to sendmail variables in template diff --git a/clamav-devel/libclamav/mbox.c b/clamav-devel/libclamav/mbox.c index a91078b0a..fa0279684 100644 --- a/clamav-devel/libclamav/mbox.c +++ b/clamav-devel/libclamav/mbox.c @@ -17,6 +17,9 @@ * * Change History: * $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 * Added thread safety * @@ -216,7 +219,7 @@ * 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 #include "clamav-config.h" @@ -651,7 +654,7 @@ parseEmailHeader(message *m, const char *line, const table_t *rfc821Table) static int /* success or fail */ 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; text *aText; blob *blobList[MAX_ATTACHMENTS], **blobs; @@ -668,6 +671,7 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con aText = textIn; blobs = blobsIn; + messages = NULL; mainMessage = messageIn; /* 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 * 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; + messages = cli_realloc(messages, ((multiparts + 1) * sizeof(message *))); + aMessage = messages[multiparts] = messageCreate(); 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; } - if(multiparts == 0) + if(multiparts == 0) { + if(messages) + free(messages); return 2; /* Nothing to do */ + } cli_dbgmsg("The message has %d parts\n", multiparts); 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)) textDestroy(aText); + if(messages) + free(messages); + return rc; case MESSAGE: @@ -1404,6 +1416,8 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con if(mainMessage && (mainMessage != messageIn)) messageDestroy(mainMessage); + if(messages) + free(messages); return 0; case APPLICATION: @@ -1598,6 +1612,9 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con if(mainMessage && (mainMessage != messageIn)) messageDestroy(mainMessage); + if(messages) + free(messages); + cli_dbgmsg("parseEmailBody() returning %d\n", rc); return rc; diff --git a/clamav-devel/libclamav/mbox.h b/clamav-devel/libclamav/mbox.h index e5d57dd77..4198ce85a 100644 --- a/clamav-devel/libclamav/mbox.h +++ b/clamav-devel/libclamav/mbox.h @@ -25,8 +25,6 @@ typedef enum { NOENCODING, QUOTEDPRINTABLE, BASE64, EIGHTBIT, BINARY, UUENCODE, EEXTENSION } encoding_type; -#define MAXALTERNATIVE 5 /* The maximum number of alternatives allowed in a message */ - /* tk: shut up manager.c warning */ #include