Browse code

Backtrack quoted-printable broken fix

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

Nigel Horne authored on 2004/12/15 01:45:43
Showing 2 changed files
... ...
@@ -1,9 +1,14 @@
1
+Tue Dec 14 16:43:51 GMT 2004 (njh)
2
+----------------------------------
3
+  * libclamav/message.c: removed fix from Wed Dec  1 12:14:46 GMT 2004. The
4
+			original code was correct.
5
+
1 6
 Tue Dec 14 11:36:43 GMT 2004 (trog)
2 7
 -----------------------------------
3 8
   * libclamav/vba_extract.c:
4 9
 	- Add signature for MacOffice 2004
5 10
 	- Guess endianness of unknown versions of MS Office.
6
-			
11
+
7 12
 Tue Dec 14 11:15:22 GMT 2004 (trog)
8 13
 -----------------------------------
9 14
   * sigtool/options.c sigtool/sigtool.c: New options: --vba and --vba-hex
... ...
@@ -13,6 +18,15 @@ Tue Dec 14 10:30:15 GMT 2004 (njh)
13 13
 ----------------------------------
14 14
   * libclamav/message.c:	better recovery if memory softlimit is hit
15 15
 
16
+Tue Dec 14 10:46:44 GMT 2004 (njh)
17
+----------------------------------
18
+  * clamav-milter:	Fix crash on BSD if DNS is incorrectly setup
19
+			Single thread access to the Version strings
20
+
21
+Tue Dec 14 10:30:15 GMT 2004 (njh)
22
+----------------------------------
23
+  * libclamav/message.c:	better recovery if memory softlimit is hit
24
+
16 25
 Mon Dec 13 11:21:28 GMT 2004 (njh)
17 26
 ----------------------------------
18 27
   * clamav-milter:	INSTALL: Added notes about FreeBSD5
... ...
@@ -28,7 +42,7 @@ Sun Dec 12 20:34:03 GMT 2004 (njh)
28 28
 Sun Dec 12 19:40:10 UTC 2004 (acab)
29 29
 -----------------------------------
30 30
   * libclamav: upx:  improved PE rebuild - debug info on failure
31
-  
31
+ 
32 32
 Fri Dec 10 15:21:48 GMT 2004 (njh)
33 33
 ----------------------------------
34 34
   * libclamav/message.c:	Warn if the content-type contains a blank entry
... ...
@@ -17,6 +17,9 @@
17 17
  *
18 18
  * Change History:
19 19
  * $Log: message.c,v $
20
+ * Revision 1.131  2004/12/14 16:45:43  nigelhorne
21
+ * Backtrack quoted-printable broken fix
22
+ *
20 23
  * Revision 1.130  2004/12/14 10:27:57  nigelhorne
21 24
  * Better reclaiming when running short of memory
22 25
  *
... ...
@@ -387,7 +390,7 @@
387 387
  * uuencodebegin() no longer static
388 388
  *
389 389
  */
390
-static	char	const	rcsid[] = "$Id: message.c,v 1.130 2004/12/14 10:27:57 nigelhorne Exp $";
390
+static	char	const	rcsid[] = "$Id: message.c,v 1.131 2004/12/14 16:45:43 nigelhorne Exp $";
391 391
 
392 392
 #if HAVE_CONFIG_H
393 393
 #include "clamav-config.h"
... ...
@@ -458,10 +461,10 @@ static	int	simil(const char *str1, const char *str2);
458 458
 static	const	struct	encoding_map {
459 459
 	const	char	*string;
460 460
 	encoding_type	type;
461
-} encoding_map[] = {	/* rfc1521 */
461
+} encoding_map[] = {	/* rfc2045 */
462 462
 	{	"7bit",			NOENCODING	},
463 463
 	{	"text/plain",		NOENCODING	},
464
-	{	"quoted-printable",	QUOTEDPRINTABLE	},	/* rfc1521 */
464
+	{	"quoted-printable",	QUOTEDPRINTABLE	},	/* rfc2045 */
465 465
 	{	"base64",		BASE64		},	/* rfc2045 */
466 466
 	{	"8bit",			EIGHTBIT	},
467 467
 	{	"binary",		BINARY		},
... ...
@@ -810,7 +813,7 @@ messageAddArguments(message *m, const char *s)
810 810
 		data = strchr(string, '=');
811 811
 
812 812
 		/*
813
-		 * Some spam breaks RFC1521 by using ':' instead of '='
813
+		 * Some spam breaks RFC2045 by using ':' instead of '='
814 814
 		 * e.g.:
815 815
 		 *	Content-Type: text/html; charset:ISO-8859-1
816 816
 		 * should be:
... ...
@@ -837,7 +840,7 @@ messageAddArguments(message *m, const char *s)
837 837
 
838 838
 		/*
839 839
 		 * Handle white space to the right of the equals sign
840
-		 * This breaks RFC1521 which has:
840
+		 * This breaks RFC2045 which has:
841 841
 		 *	parameter := attribute "=" value
842 842
 		 *	attribute := token   ; case-insensitive
843 843
 		 *	token  :=  1*<any (ASCII) CHAR except SPACE, CTLs,
... ...
@@ -1785,7 +1788,7 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
1785 1785
 			}
1786 1786
 
1787 1787
 			/*
1788
-			 * According to RFC1521, '=' is used to pad out
1788
+			 * According to RFC2045, '=' is used to pad out
1789 1789
 			 * the last byte and should be used as evidence
1790 1790
 			 * of the end of the data. Some mail clients
1791 1791
 			 * annoyingly then put plain text after the '='
... ...
@@ -2178,11 +2181,23 @@ decodeLine(message *m, encoding_type et, const char *line, unsigned char *buf, s
2178 2178
 				break;
2179 2179
 			}
2180 2180
 
2181
+#if	0
2181 2182
 			/*
2182
-			 * Section 5.1 of RFC1521 states that any number of white
2183
+			 * Section 5.1 of RFC2045 states that any number of white
2183 2184
 			 * space characters may appear on the end of the line
2184 2185
 			 * before the final '=' which indicates a soft break.
2186
+			 *
2187
+			 * Section 6.7.(3) of RFC2045 is no clearer.
2188
+			 *
2185 2189
 			 * This means that we have to do a look ahead here.
2190
+			 *
2191
+			 * This is a real pain because not everyone is
2192
+			 * aware of the implication of the above sentence,
2193
+			 * namely that you must encode any white space before
2194
+			 * the final '=' to ensure it is correctly transfered
2195
+			 * otherwise it is dropped.
2196
+			 * This code adheres to the RFC, but I don't think most
2197
+			 * other software does so I may have to change it
2186 2198
 			 */
2187 2199
 			p2 = strchr(line, '\0');
2188 2200
 			if(p2 == line) {	/* empty line */
... ...
@@ -2216,7 +2231,7 @@ decodeLine(message *m, encoding_type et, const char *line, unsigned char *buf, s
2216 2216
 					if((*++line == '\0') || (*line == '\n')) {
2217 2217
 						/*
2218 2218
 						 * broken e-mail, not
2219
-						 * adhering to RFC1521
2219
+						 * adhering to RFC2045
2220 2220
 						 */
2221 2221
 						*buf++ = byte;
2222 2222
 						break;
... ...
@@ -2229,6 +2244,37 @@ decodeLine(message *m, encoding_type et, const char *line, unsigned char *buf, s
2229 2229
 					*buf++ = *line;
2230 2230
 				line++;
2231 2231
 			}
2232
+#else
2233
+			softbreak = FALSE;
2234
+			while(*line) {
2235
+				if(*line == '=') {
2236
+					unsigned char byte;
2237
+
2238
+					if((*++line == '\0') || (*line == '\n')) {
2239
+						softbreak = TRUE;
2240
+						/* soft line break */
2241
+						break;
2242
+					}
2243
+
2244
+					byte = hex(*line);
2245
+
2246
+					if((*++line == '\0') || (*line == '\n')) {
2247
+						/*
2248
+						 * broken e-mail, not
2249
+						 * adhering to RFC2045
2250
+						 */
2251
+						*buf++ = byte;
2252
+						break;
2253
+					}
2254
+
2255
+					byte <<= 4;
2256
+					byte += hex(*line);
2257
+					*buf++ = byte;
2258
+				} else
2259
+					*buf++ = *line;
2260
+				line++;
2261
+			}
2262
+#endif
2232 2263
 			if(!softbreak)
2233 2264
 				/* Put the new line back in */
2234 2265
 				*buf++ = '\n';
... ...
@@ -2238,7 +2284,7 @@ decodeLine(message *m, encoding_type et, const char *line, unsigned char *buf, s
2238 2238
 			if(line == NULL)
2239 2239
 				break;
2240 2240
 			/*
2241
-			 * RFC1521 sets the maximum length to 76 bytes
2241
+			 * RFC2045 sets the maximum length to 76 bytes
2242 2242
 			 * but many e-mail clients ignore that
2243 2243
 			 */
2244 2244
 			copy = strdup(line);
... ...
@@ -2531,7 +2577,7 @@ hex(char c)
2531 2531
 	cli_dbgmsg("Illegal hex character '%c'\n", c);
2532 2532
 
2533 2533
 	/*
2534
-	 * Some mails (notably some spam) break RFC1521 by failing to encode
2534
+	 * Some mails (notably some spam) break RFC2045 by failing to encode
2535 2535
 	 * the '=' character
2536 2536
 	 */
2537 2537
 	return '=';