git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@1150 77e5149b-7576-45b1-b177-96237e5ba77b
Nigel Horne authored on 2004/12/01 21:16:15... | ... |
@@ -1,3 +1,10 @@ |
1 |
+Wed Dec 1 12:14:46 GMT 2004 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * libeclamav/message.c: Part of rule 3 of paragraph 5.1 of RFC1521 was |
|
4 |
+ not being implemented, which meant that quoted-printable |
|
5 |
+ attachments with spaces before the '=' character at the end |
|
6 |
+ of soft breakon lines where not being correctly decoded |
|
7 |
+ |
|
1 | 8 |
Tue Nov 30 16:47:54 CET 2004 (tk) |
2 | 9 |
--------------------------------- |
3 | 10 |
* improved support for BSDI BSD/OS (access to test environment provided by |
... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: message.c,v $ |
20 |
+ * Revision 1.128 2004/12/01 12:12:27 nigelhorne |
|
21 |
+ * Part of rule 3 of paragraph 5.1 of RFC1521 was not being implemented |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.127 2004/11/30 12:03:57 nigelhorne |
21 | 24 |
* Handle unbalanced quote characters in headers better |
22 | 25 |
* |
... | ... |
@@ -378,7 +381,7 @@ |
378 | 378 |
* uuencodebegin() no longer static |
379 | 379 |
* |
380 | 380 |
*/ |
381 |
-static char const rcsid[] = "$Id: message.c,v 1.127 2004/11/30 12:03:57 nigelhorne Exp $"; |
|
381 |
+static char const rcsid[] = "$Id: message.c,v 1.128 2004/12/01 12:12:27 nigelhorne Exp $"; |
|
382 | 382 |
|
383 | 383 |
#if HAVE_CONFIG_H |
384 | 384 |
#include "clamav-config.h" |
... | ... |
@@ -394,7 +397,7 @@ static char const rcsid[] = "$Id: message.c,v 1.127 2004/11/30 12:03:57 nigelhor |
394 | 394 |
#endif |
395 | 395 |
#endif |
396 | 396 |
|
397 |
-#if C_DARWIN |
|
397 |
+#ifdef C_DARWIN |
|
398 | 398 |
#include <sys/types.h> |
399 | 399 |
#endif |
400 | 400 |
#include <stdlib.h> |
... | ... |
@@ -611,7 +614,7 @@ messageSetMimeType(message *mess, const char *type) |
611 | 611 |
typeval = tableFind(mime_table, type); |
612 | 612 |
|
613 | 613 |
if(typeval != -1) { |
614 |
- mess->mimeType = typeval; |
|
614 |
+ mess->mimeType = (mime_type)typeval; |
|
615 | 615 |
return 1; |
616 | 616 |
} else if(mess->mimeType == NOMIME) { |
617 | 617 |
if(strncasecmp(type, "x-", 2) == 0) |
... | ... |
@@ -2166,14 +2169,36 @@ decodeLine(message *m, encoding_type et, const char *line, unsigned char *buf, s |
2166 | 2166 |
break; |
2167 | 2167 |
} |
2168 | 2168 |
|
2169 |
- softbreak = FALSE; |
|
2170 |
- while(*line) { |
|
2169 |
+ /* |
|
2170 |
+ * Section 5.1 of RFC1521 states that any number of white |
|
2171 |
+ * space characters may appear on the end of the line |
|
2172 |
+ * before the final '=' which indicates a soft break. |
|
2173 |
+ * This means that we have to do a look ahead here. |
|
2174 |
+ */ |
|
2175 |
+ p2 = strchr(line, '\0'); |
|
2176 |
+ if(p2 == line) { /* empty line */ |
|
2177 |
+ *buf++ = '\n'; |
|
2178 |
+ break; |
|
2179 |
+ } |
|
2180 |
+ if(*--p2 == '=') { |
|
2181 |
+ softbreak = TRUE; |
|
2182 |
+ do |
|
2183 |
+ --p2; |
|
2184 |
+ while(isspace(*p2) && (p2 > line)); |
|
2185 |
+ } else |
|
2186 |
+ softbreak = FALSE; |
|
2187 |
+ |
|
2188 |
+ /* |
|
2189 |
+ * p2 now points to the last significant character on the line |
|
2190 |
+ */ |
|
2191 |
+ while(line <= p2) { |
|
2171 | 2192 |
if(*line == '=') { |
2172 | 2193 |
unsigned char byte; |
2173 | 2194 |
|
2174 | 2195 |
if((*++line == '\0') || (*line == '\n')) { |
2175 |
- softbreak = TRUE; |
|
2176 |
- /* soft line break */ |
|
2196 |
+ /* soft line break detected */ |
|
2197 |
+ if(!softbreak) |
|
2198 |
+ cli_warnmsg("Unexpected soft line break\n"); |
|
2177 | 2199 |
break; |
2178 | 2200 |
} |
2179 | 2201 |
|
... | ... |
@@ -2330,9 +2355,9 @@ decode(message *m, const char *in, unsigned char *out, unsigned char (*decoder)( |
2330 | 2330 |
unsigned char cb1, cb2, cb3; /* carried over from last line */ |
2331 | 2331 |
|
2332 | 2332 |
#ifdef CL_DEBUG |
2333 |
- cli_dbgmsg("decode %s (len %d isFast %d base64chars %d)\n", in, |
|
2333 |
+ /*cli_dbgmsg("decode %s (len %d isFast %d base64chars %d)\n", in, |
|
2334 | 2334 |
in ? strlen(in) : 0, |
2335 |
- isFast, m->base64chars); |
|
2335 |
+ isFast, m->base64chars);*/ |
|
2336 | 2336 |
#endif |
2337 | 2337 |
|
2338 | 2338 |
cb1 = cb2 = cb3 = '\0'; |