Browse code

Better handling of messages with lots of consecutive blank lines

git-svn: trunk@1892

Nigel Horne authored on 2006/04/07 20:26:34
Showing 2 changed files
... ...
@@ -1,3 +1,8 @@
1
+Fri Apr  7 12:25:20 BST 2006 (njh)
2
+----------------------------------
3
+  * libclamav/mbox.c:		Better handling of messages with lots of
4
+  					consecutive blank lines
5
+
1 6
 Fri Apr  7 11:13:29 BST 2006 (trog)
2 7
 -----------------------------------
3 8
   * libclamav/unrar/unrar.c: Fix error path error leaks.
... ...
@@ -15,7 +15,7 @@
15 15
  *  along with this program; if not, write to the Free Software
16 16
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 17
  */
18
-static	char	const	rcsid[] = "$Id: mbox.c,v 1.281 2006/04/07 10:15:49 nigelhorne Exp $";
18
+static	char	const	rcsid[] = "$Id: mbox.c,v 1.282 2006/04/07 11:24:22 nigelhorne Exp $";
19 19
 
20 20
 #if HAVE_CONFIG_H
21 21
 #include "clamav-config.h"
... ...
@@ -1169,7 +1169,7 @@ parseEmailFile(FILE *fin, const table_t *rfc821, const char *firstLine, const ch
1169 1169
 {
1170 1170
 	bool inHeader = TRUE;
1171 1171
 	bool contMarker = FALSE;
1172
-	bool lastWasBlank = FALSE;
1172
+	bool lastWasBlank = FALSE, lastBodyLineWasBlank = FALSE;
1173 1173
 	message *ret;
1174 1174
 	bool anyHeadersFound = FALSE;
1175 1175
 	int commandNumber = -1;
... ...
@@ -1364,9 +1364,19 @@ parseEmailFile(FILE *fin, const table_t *rfc821, const char *firstLine, const ch
1364 1364
 			if(uudecodeFile(ret, line, dir, fin) < 0)
1365 1365
 				if(messageAddStr(ret, line) < 0)
1366 1366
 					break;
1367
-		} else
1367
+		} else {
1368
+			if(line == NULL) {
1369
+				if(lastBodyLineWasBlank) {
1370
+					cli_dbgmsg("Ignoring consecutive blank lines in the body\n");
1371
+					continue;
1372
+				}
1373
+				lastBodyLineWasBlank = TRUE;
1374
+			} else
1375
+				lastBodyLineWasBlank = FALSE;
1376
+
1368 1377
 			if(messageAddStr(ret, line) < 0)
1369 1378
 				break;
1379
+		}
1370 1380
 	} while(getline_from_mbox(buffer, sizeof(buffer) - 1, fin) != NULL);
1371 1381
 
1372 1382
 	if(fullline) {