git-svn: trunk@990
Nigel Horne authored on 2004/10/11 19:56:17... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: message.c,v $ |
20 |
+ * Revision 1.98 2004/10/11 10:56:17 nigelhorne |
|
21 |
+ * Reimplement squeeze ads sanisiseBase64 |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.97 2004/10/06 17:21:46 nigelhorne |
21 | 24 |
* Code tidy |
22 | 25 |
* |
... | ... |
@@ -288,7 +291,7 @@ |
288 | 288 |
* uuencodebegin() no longer static |
289 | 289 |
* |
290 | 290 |
*/ |
291 |
-static char const rcsid[] = "$Id: message.c,v 1.97 2004/10/06 17:21:46 nigelhorne Exp $"; |
|
291 |
+static char const rcsid[] = "$Id: message.c,v 1.98 2004/10/11 10:56:17 nigelhorne Exp $"; |
|
292 | 292 |
|
293 | 293 |
#if HAVE_CONFIG_H |
294 | 294 |
#include "clamav-config.h" |
... | ... |
@@ -342,7 +345,7 @@ static void messageIsEncoding(message *m); |
342 | 342 |
static const text *binhexBegin(const message *m); |
343 | 343 |
static unsigned char *decodeLine(message *m, encoding_type enctype, const char *line, unsigned char *buf, size_t buflen); |
344 | 344 |
static unsigned char *decode(message *m, const char *in, unsigned char *out, unsigned char (*decoder)(char), bool isFast); |
345 |
-static void squeeze(char *s); |
|
345 |
+static void sanitiseBase64(char *s); |
|
346 | 346 |
static unsigned char hex(char c); |
347 | 347 |
static unsigned char base64(char c); |
348 | 348 |
static unsigned char uudecode(char c); |
... | ... |
@@ -2031,7 +2034,7 @@ decodeLine(message *m, encoding_type et, const char *line, unsigned char *buf, s |
2031 | 2031 |
if(copy == NULL) |
2032 | 2032 |
break; |
2033 | 2033 |
|
2034 |
- squeeze(copy); |
|
2034 |
+ sanitiseBase64(copy); |
|
2035 | 2035 |
|
2036 | 2036 |
p2 = strchr(copy, '='); |
2037 | 2037 |
if(p2) |
... | ... |
@@ -2094,21 +2097,21 @@ decodeLine(message *m, encoding_type et, const char *line, unsigned char *buf, s |
2094 | 2094 |
} |
2095 | 2095 |
|
2096 | 2096 |
/* |
2097 |
- * Remove the spaces from the middle of a string. Spaces shouldn't appear |
|
2098 |
- * mid string in base64 files, but some broken mail clients ignore such |
|
2099 |
- * errors rather than discarding the mail, and virus writers exploit this bug |
|
2097 |
+ * Remove the non base64 characters such as spaces from a string. Spaces |
|
2098 |
+ * shouldn't appear mid string in base64 files, but some broken mail clients |
|
2099 |
+ * ignore such errors rather than discarding the mail, and virus writers |
|
2100 |
+ * exploit this bug |
|
2100 | 2101 |
*/ |
2101 | 2102 |
static void |
2102 |
-squeeze(char *s) |
|
2103 |
+sanitiseBase64(char *s) |
|
2103 | 2104 |
{ |
2104 |
- while((s = strchr(s, ' ')) != NULL) { |
|
2105 |
- /*strcpy(s, &s[1]);*/ /* overlapping strcpy */ |
|
2106 |
- |
|
2107 |
- char *p1; |
|
2105 |
+ for(; *s; s++) |
|
2106 |
+ if(base64Table[*s] == 255) { |
|
2107 |
+ char *p1; |
|
2108 | 2108 |
|
2109 |
- for(p1 = s; p1[0] != '\0'; p1++) |
|
2110 |
- p1[0] = p1[1]; |
|
2111 |
- } |
|
2109 |
+ for(p1 = s; p1[0] != '\0'; p1++) |
|
2110 |
+ p1[0] = p1[1]; |
|
2111 |
+ } |
|
2112 | 2112 |
} |
2113 | 2113 |
|
2114 | 2114 |
/* |