Browse code

Handle trailing newline

git-svn: trunk@2107

Nigel Horne authored on 2006/07/22 03:19:46
Showing 2 changed files
... ...
@@ -1,3 +1,9 @@
1
+Fri Jul 21 19:18:08 BST 2006 (njh)
2
+----------------------------------
3
+  * libclamav/tnef.c:	Handle trailing newline at the end of winmail.dat,
4
+				bug reported by Menno Smits
5
+				<menno*netboxblue.com>
6
+
1 7
 Thu Jul 20 01:56:10 BST 2006 (njh)
2 8
 ----------------------------------
3 9
   * clamav-milter:	Code tidy: more consistent use of in_addr_t
... ...
@@ -25,7 +25,7 @@
25 25
 #include "clamav-config.h"
26 26
 #endif
27 27
 
28
-static	char	const	rcsid[] = "$Id: tnef.c,v 1.36 2006/06/20 19:36:33 njh Exp $";
28
+static	char	const	rcsid[] = "$Id: tnef.c,v 1.37 2006/07/21 18:16:28 njh Exp $";
29 29
 
30 30
 #include <stdio.h>
31 31
 #include <fcntl.h>
... ...
@@ -374,8 +374,18 @@ tnef_header(FILE *fp, uint8_t *part, uint16_t *type, uint16_t *tag, int32_t *len
374 374
 	if(*part == (uint8_t)0)
375 375
 		return 0;
376 376
 
377
-	if(fread(&i32, sizeof(uint32_t), 1, fp) != 1)
377
+	if(fread(&i32, sizeof(uint32_t), 1, fp) != 1) {
378
+		if((*part == '\n') && feof(fp)) {
379
+			/*
380
+			 * trailing newline in the file, could be caused by
381
+			 * quoted-printable encoding in the source message
382
+			 * missing a final '='
383
+			 */
384
+			cli_dbgmsg("tnef_header: ignoring trailing newline\n");
385
+			return 0;
386
+		}
378 387
 		return -1;
388
+	}
379 389
 
380 390
 	i32 = host32(i32);
381 391
 	*tag = (uint16_t)(i32 & 0xFFFF);