From 420df63ce5937ed0c6a08d4f9e14b2f1d775c3ac Mon Sep 17 00:00:00 2001 From: Nigel Horne Date: Tue, 21 Sep 2004 14:57:37 +0000 Subject: [PATCH] Handle blank lines in text/plain messages git-svn: trunk@916 --- clamav-devel/ChangeLog | 4 ++++ clamav-devel/libclamav/line.c | 11 ++++++++++- clamav-devel/libclamav/message.c | 17 +++++++++++++---- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/clamav-devel/ChangeLog b/clamav-devel/ChangeLog index fe01f43f1..e9c9e488e 100644 --- a/clamav-devel/ChangeLog +++ b/clamav-devel/ChangeLog @@ -1,3 +1,7 @@ +Tue Sep 21 15:56:35 BST 2004 (njh) +---------------------------------- + * libclamav: Fix handling of empty lines in text/plain emails + Tue Sep 21 13:20:31 BST 2004 (njh) ---------------------------------- * libclamav/mbox.c: Fallback to CURLOPT_FILE if CURLOPT_WRITEDATA isn't diff --git a/clamav-devel/libclamav/line.c b/clamav-devel/libclamav/line.c index a0ae9941b..720a7445c 100644 --- a/clamav-devel/libclamav/line.c +++ b/clamav-devel/libclamav/line.c @@ -16,6 +16,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Log: line.c,v $ + * Revision 1.4 2004/09/21 14:55:26 nigelhorne + * Handle blank lines in text/plain messages + * * Revision 1.3 2004/08/25 12:30:36 nigelhorne * Use memcpy rather than strcpy * @@ -27,7 +30,7 @@ * */ -static char const rcsid[] = "$Id: line.c,v 1.3 2004/08/25 12:30:36 nigelhorne Exp $"; +static char const rcsid[] = "$Id: line.c,v 1.4 2004/09/21 14:55:26 nigelhorne Exp $"; #if HAVE_CONFIG_H #include "clamav-config.h" @@ -35,10 +38,15 @@ static char const rcsid[] = "$Id: line.c,v 1.3 2004/08/25 12:30:36 nigelhorne Ex #include #include +#include #include "line.h" #include "others.h" +#ifndef CL_DEBUG +#define NDEBUG /* map CLAMAV debug onto standard */ +#endif + #ifdef OLD line_t * lineCreate(const char *data) @@ -104,6 +112,7 @@ lineCreate(const char *data) line_t * lineLink(line_t *line) { + assert(line != NULL); if(line[0] == 127) { cli_warnmsg("lineLink: linkcount too large\n"); return NULL; diff --git a/clamav-devel/libclamav/message.c b/clamav-devel/libclamav/message.c index 6caf40e8a..6ba0fb67e 100644 --- a/clamav-devel/libclamav/message.c +++ b/clamav-devel/libclamav/message.c @@ -17,6 +17,9 @@ * * Change History: * $Log: message.c,v $ + * Revision 1.88 2004/09/21 14:55:26 nigelhorne + * Handle blank lines in text/plain messages + * * Revision 1.87 2004/09/20 12:44:03 nigelhorne * Fix parsing error on mime arguments * @@ -258,14 +261,14 @@ * uuencodebegin() no longer static * */ -static char const rcsid[] = "$Id: message.c,v 1.87 2004/09/20 12:44:03 nigelhorne Exp $"; +static char const rcsid[] = "$Id: message.c,v 1.88 2004/09/21 14:55:26 nigelhorne Exp $"; #if HAVE_CONFIG_H #include "clamav-config.h" #endif #ifndef CL_DEBUG -/*#define NDEBUG /* map CLAMAV debug onto standard */ +#define NDEBUG /* map CLAMAV debug onto standard */ #endif #ifdef CL_THREAD_SAFE @@ -1591,7 +1594,10 @@ messageToText(message *m) textDestroy(first); return NULL; } - last->t_line = lineLink(t_line->t_line); + if(t_line->t_line) + last->t_line = lineLink(t_line->t_line); + else + last->t_line = NULL; /* empty line */ } if(last) last->t_next = NULL; @@ -1624,7 +1630,10 @@ messageToText(message *m) textDestroy(first); return NULL; } - last->t_line = lineLink(t_line->t_line); + if(t_line->t_line) + last->t_line = lineLink(t_line->t_line); + else + last->t_line = NULL; /* empty line */ } continue; }