From 73ddf91f8737497413d0d0defd7bdc605172ec7b Mon Sep 17 00:00:00 2001 From: Nigel Horne Date: Sat, 15 Sep 2007 09:00:57 +0000 Subject: [PATCH] More cleanups git-svn: trunk@3221 --- ChangeLog | 4 ++++ libclamav/mbox.c | 14 +++++++------- libclamav/message.c | 11 +++++++---- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index e4bd53534..9a982c254 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sat Sep 15 09:13:14 BST 2007 (njh) +---------------------------------- + * libclamav: More cleanups + Fri Sep 14 20:16:20 CEST 2007 (tk) ---------------------------------- * libclamav/matcher-ac.c: minor optimisation diff --git a/libclamav/mbox.c b/libclamav/mbox.c index 5aeb72996..f974c9b3e 100644 --- a/libclamav/mbox.c +++ b/libclamav/mbox.c @@ -2512,9 +2512,10 @@ parseEmailBody(message *messageIn, text *textIn, mbox_ctx *mctx, unsigned int re htmltextPart = getTextPart(messages, multiparts); - if(htmltextPart >= 0) - aText = textAddMessage(aText, messages[htmltextPart]); - else + if(htmltextPart >= 0) { + if(messageGetBody(messages[htmltextPart])) + aText = textAddMessage(aText, messages[htmltextPart]); + } else /* * There isn't an HTML bit. If there's a * multipart bit, it'll may be in there @@ -3187,14 +3188,13 @@ getTextPart(message *const messages[], size_t size) size_t i; int textpart = -1; - for(i = 0; i < size; i++) { - assert(messages[i] != NULL); - if(messageGetMimeType(messages[i]) == TEXT) { + for(i = 0; i < size; i++) + if(messages[i] && (messageGetMimeType(messages[i]) == TEXT)) { if(strcasecmp(messageGetMimeSubtype(messages[i]), "html") == 0) return (int)i; textpart = (int)i; } - } + return textpart; } diff --git a/libclamav/message.c b/libclamav/message.c index 9f07b03f6..6d417f68b 100644 --- a/libclamav/message.c +++ b/libclamav/message.c @@ -15,6 +15,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. + * + * TODO: Optimise messageExport, decodeLine, messageIsEncoding */ static char const rcsid[] = "$Id: message.c,v 1.195 2007/02/12 20:46:09 njh Exp $"; @@ -1511,7 +1513,7 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy /* * Find the filename to decode */ - if(((enctype == YENCODE) && yEncBegin(m)) || ((i == 0) && yEncBegin(m))) { + if(((enctype == YENCODE) || (i == 0)) && yEncBegin(m)) { const char *f; /* @@ -1540,9 +1542,10 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy } else { if(enctype == UUENCODE) { /* - * The body will have been stripped out by the fast track visa - * system. Treat as plain/text, which means we'll still scan - * for funnies outside of the uuencoded portion. + * The body will have been stripped out by the + * fast track visa system. Treat as plain/text, + * which means we'll still scan for funnies + * outside of the uuencoded portion. */ cli_dbgmsg("messageExport: treat uuencode as text/plain\n"); enctype = m->encodingTypes[i] = NOENCODING;