Browse code

Handle blank lines in text/plain messages

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@916 77e5149b-7576-45b1-b177-96237e5ba77b

Nigel Horne authored on 2004/09/21 23:57:37
Showing 3 changed files
... ...
@@ -1,3 +1,7 @@
1
+Tue Sep 21 15:56:35 BST 2004 (njh)
2
+----------------------------------
3
+  * libclamav:	Fix handling of empty lines in text/plain emails
4
+
1 5
 Tue Sep 21 13:20:31 BST 2004 (njh)
2 6
 ----------------------------------
3 7
   * libclamav/mbox.c:	Fallback to CURLOPT_FILE if CURLOPT_WRITEDATA isn't
... ...
@@ -16,6 +16,9 @@
16 16
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 17
  *
18 18
  * $Log: line.c,v $
19
+ * Revision 1.4  2004/09/21 14:55:26  nigelhorne
20
+ * Handle blank lines in text/plain messages
21
+ *
19 22
  * Revision 1.3  2004/08/25 12:30:36  nigelhorne
20 23
  * Use memcpy rather than strcpy
21 24
  *
... ...
@@ -27,7 +30,7 @@
27 27
  *
28 28
  */
29 29
 
30
-static	char	const	rcsid[] = "$Id: line.c,v 1.3 2004/08/25 12:30:36 nigelhorne Exp $";
30
+static	char	const	rcsid[] = "$Id: line.c,v 1.4 2004/09/21 14:55:26 nigelhorne Exp $";
31 31
 
32 32
 #if HAVE_CONFIG_H
33 33
 #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
35 35
 
36 36
 #include <stdio.h>
37 37
 #include <string.h>
38
+#include <assert.h>
38 39
 
39 40
 #include "line.h"
40 41
 #include "others.h"
41 42
 
43
+#ifndef	CL_DEBUG
44
+#define	NDEBUG	/* map CLAMAV debug onto standard */
45
+#endif
46
+
42 47
 #ifdef	OLD
43 48
 line_t *
44 49
 lineCreate(const char *data)
... ...
@@ -104,6 +112,7 @@ lineCreate(const char *data)
104 104
 line_t *
105 105
 lineLink(line_t *line)
106 106
 {
107
+	assert(line != NULL);
107 108
 	if(line[0] == 127) {
108 109
 		cli_warnmsg("lineLink: linkcount too large\n");
109 110
 		return NULL;
... ...
@@ -17,6 +17,9 @@
17 17
  *
18 18
  * Change History:
19 19
  * $Log: message.c,v $
20
+ * Revision 1.88  2004/09/21 14:55:26  nigelhorne
21
+ * Handle blank lines in text/plain messages
22
+ *
20 23
  * Revision 1.87  2004/09/20 12:44:03  nigelhorne
21 24
  * Fix parsing error on mime arguments
22 25
  *
... ...
@@ -258,14 +261,14 @@
258 258
  * uuencodebegin() no longer static
259 259
  *
260 260
  */
261
-static	char	const	rcsid[] = "$Id: message.c,v 1.87 2004/09/20 12:44:03 nigelhorne Exp $";
261
+static	char	const	rcsid[] = "$Id: message.c,v 1.88 2004/09/21 14:55:26 nigelhorne Exp $";
262 262
 
263 263
 #if HAVE_CONFIG_H
264 264
 #include "clamav-config.h"
265 265
 #endif
266 266
 
267 267
 #ifndef	CL_DEBUG
268
-/*#define	NDEBUG	/* map CLAMAV debug onto standard */
268
+#define	NDEBUG	/* map CLAMAV debug onto standard */
269 269
 #endif
270 270
 
271 271
 #ifdef CL_THREAD_SAFE
... ...
@@ -1591,7 +1594,10 @@ messageToText(message *m)
1591 1591
 					textDestroy(first);
1592 1592
 				return NULL;
1593 1593
 			}
1594
-			last->t_line = lineLink(t_line->t_line);
1594
+			if(t_line->t_line)
1595
+				last->t_line = lineLink(t_line->t_line);
1596
+			else
1597
+				last->t_line = NULL;	/* empty line */
1595 1598
 		}
1596 1599
 		if(last)
1597 1600
 			last->t_next = NULL;
... ...
@@ -1624,7 +1630,10 @@ messageToText(message *m)
1624 1624
 						textDestroy(first);
1625 1625
 					return NULL;
1626 1626
 				}
1627
-				last->t_line = lineLink(t_line->t_line);
1627
+				if(t_line->t_line)
1628
+					last->t_line = lineLink(t_line->t_line);
1629
+				else
1630
+					last->t_line = NULL;	/* empty line */
1628 1631
 			}
1629 1632
 			continue;
1630 1633
 		}