git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@1229 77e5149b-7576-45b1-b177-96237e5ba77b
Nigel Horne authored on 2005/01/06 06:11:18... | ... |
@@ -1,3 +1,10 @@ |
1 |
+Wed Jan 5 21:09:14 GMT 2005 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav/message.c: Fix crash caused when looking for non-existant |
|
4 |
+ uuencoded files. This happens when the stated encoding |
|
5 |
+ method is wrong so we have to try all methods and |
|
6 |
+ including those which will fail |
|
7 |
+ |
|
1 | 8 |
Sat Jan 1 15:56:48 GMT 2005 (njh) |
2 | 9 |
---------------------------------- |
3 | 10 |
* libclamav/mbox.c: Changes handling of unbalanced quotes in |
... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: message.c,v $ |
20 |
+ * Revision 1.136 2005/01/05 21:07:15 nigelhorne |
|
21 |
+ * Fix crash when looking for uuencoded attachment fails |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.135 2005/01/01 12:52:58 nigelhorne |
21 | 24 |
* Some uuencoded viruses were getting through |
22 | 25 |
* |
... | ... |
@@ -402,7 +405,7 @@ |
402 | 402 |
* uuencodebegin() no longer static |
403 | 403 |
* |
404 | 404 |
*/ |
405 |
-static char const rcsid[] = "$Id: message.c,v 1.135 2005/01/01 12:52:58 nigelhorne Exp $"; |
|
405 |
+static char const rcsid[] = "$Id: message.c,v 1.136 2005/01/05 21:07:15 nigelhorne Exp $"; |
|
406 | 406 |
|
407 | 407 |
#if HAVE_CONFIG_H |
408 | 408 |
#include "clamav-config.h" |
... | ... |
@@ -1959,8 +1962,10 @@ messageToText(message *m) |
1959 | 1959 |
} |
1960 | 1960 |
|
1961 | 1961 |
if(last == NULL) { |
1962 |
- if(first) |
|
1962 |
+ if(first) { |
|
1963 |
+ last->t_next = NULL; |
|
1963 | 1964 |
textDestroy(first); |
1965 |
+ } |
|
1964 | 1966 |
return NULL; |
1965 | 1967 |
} |
1966 | 1968 |
if(t_line->t_line) |
... | ... |
@@ -1975,8 +1980,10 @@ messageToText(message *m) |
1975 | 1975 |
|
1976 | 1976 |
if(t_line == NULL) { |
1977 | 1977 |
/*cli_warnmsg("UUENCODED attachment is missing begin statement\n");*/ |
1978 |
- if(first) |
|
1978 |
+ if(first) { |
|
1979 |
+ last->t_next = NULL; |
|
1979 | 1980 |
textDestroy(first); |
1981 |
+ } |
|
1980 | 1982 |
return NULL; |
1981 | 1983 |
} |
1982 | 1984 |
t_line = t_line->t_next; |
... | ... |
@@ -1985,8 +1992,10 @@ messageToText(message *m) |
1985 | 1985 |
|
1986 | 1986 |
if(t_line == NULL) { |
1987 | 1987 |
/*cli_warnmsg("YENCODED attachment is missing begin statement\n");*/ |
1988 |
- if(first) |
|
1988 |
+ if(first) { |
|
1989 |
+ last->t_next = NULL; |
|
1989 | 1990 |
textDestroy(first); |
1991 |
+ } |
|
1990 | 1992 |
return NULL; |
1991 | 1993 |
} |
1992 | 1994 |
t_line = t_line->t_next; |
... | ... |
@@ -2219,7 +2228,7 @@ decodeLine(message *m, encoding_type et, const char *line, unsigned char *buf, s |
2219 | 2219 |
char *p2, *copy; |
2220 | 2220 |
char base64buf[RFC2045LENGTH + 1]; |
2221 | 2221 |
|
2222 |
- /*printf("decodeLine(et = %d buflen = %u)\n", (int)et, buflen);*/ |
|
2222 |
+ /*cli_dbgmsg("decodeLine(et = %d buflen = %u)\n", (int)et, buflen);*/ |
|
2223 | 2223 |
|
2224 | 2224 |
assert(m != NULL); |
2225 | 2225 |
assert(buf != NULL); |
... | ... |
@@ -2365,8 +2374,9 @@ static void |
2365 | 2365 |
sanitiseBase64(char *s) |
2366 | 2366 |
{ |
2367 | 2367 |
#ifdef USE_TABLE |
2368 |
+ /*cli_dbgmsg("sanitiseBase64 '%s'\n", s);*/ |
|
2368 | 2369 |
for(; *s; s++) |
2369 |
- if(base64Table[(int)*s] == 255) { |
|
2370 |
+ if(base64Table[(unsigned int)(*s & 0xFF)] == 255) { |
|
2370 | 2371 |
char *p1; |
2371 | 2372 |
|
2372 | 2373 |
for(p1 = s; p1[0] != '\0'; p1++) |
... | ... |
@@ -2407,7 +2417,7 @@ decode(message *m, const char *in, unsigned char *out, unsigned char (*decoder)( |
2407 | 2407 |
unsigned char b1, b2, b3, b4; |
2408 | 2408 |
unsigned char cb1, cb2, cb3; /* carried over from last line */ |
2409 | 2409 |
|
2410 |
- /*printf("decode %s (len %d isFast %d base64chars %d)\n", in, |
|
2410 |
+ /*cli_dbgmsg("decode %s (len %d isFast %d base64chars %d)\n", in, |
|
2411 | 2411 |
in ? strlen(in) : 0, |
2412 | 2412 |
isFast, m->base64chars);*/ |
2413 | 2413 |
|
... | ... |
@@ -2580,7 +2590,7 @@ hex(char c) |
2580 | 2580 |
static unsigned char |
2581 | 2581 |
base64(char c) |
2582 | 2582 |
{ |
2583 |
- const unsigned char ret = base64Table[(int)c]; |
|
2583 |
+ const unsigned char ret = base64Table[(unsigned int)(c & 0xFF)]; |
|
2584 | 2584 |
|
2585 | 2585 |
if(ret == 255) { |
2586 | 2586 |
/*cli_dbgmsg("Illegal character <%c> in base64 encoding\n", c);*/ |