Backtrack quoted-printable broken fix

git-svn: trunk@1185
remotes/push_mirror/metadata
Nigel Horne 21 years ago
parent 11a1fcf5e4
commit 4685e39216
  1. 18
      clamav-devel/ChangeLog
  2. 66
      clamav-devel/libclamav/message.c

@ -1,9 +1,14 @@
Tue Dec 14 16:43:51 GMT 2004 (njh)
----------------------------------
* libclamav/message.c: removed fix from Wed Dec 1 12:14:46 GMT 2004. The
original code was correct.
Tue Dec 14 11:36:43 GMT 2004 (trog)
-----------------------------------
* libclamav/vba_extract.c:
- Add signature for MacOffice 2004
- Guess endianness of unknown versions of MS Office.
Tue Dec 14 11:15:22 GMT 2004 (trog)
-----------------------------------
* 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)
----------------------------------
* libclamav/message.c: better recovery if memory softlimit is hit
Tue Dec 14 10:46:44 GMT 2004 (njh)
----------------------------------
* clamav-milter: Fix crash on BSD if DNS is incorrectly setup
Single thread access to the Version strings
Tue Dec 14 10:30:15 GMT 2004 (njh)
----------------------------------
* libclamav/message.c: better recovery if memory softlimit is hit
Mon Dec 13 11:21:28 GMT 2004 (njh)
----------------------------------
* clamav-milter: INSTALL: Added notes about FreeBSD5
@ -28,7 +42,7 @@ Sun Dec 12 20:34:03 GMT 2004 (njh)
Sun Dec 12 19:40:10 UTC 2004 (acab)
-----------------------------------
* libclamav: upx: improved PE rebuild - debug info on failure
Fri Dec 10 15:21:48 GMT 2004 (njh)
----------------------------------
* libclamav/message.c: Warn if the content-type contains a blank entry

@ -17,6 +17,9 @@
*
* Change History:
* $Log: message.c,v $
* Revision 1.131 2004/12/14 16:45:43 nigelhorne
* Backtrack quoted-printable broken fix
*
* Revision 1.130 2004/12/14 10:27:57 nigelhorne
* Better reclaiming when running short of memory
*
@ -387,7 +390,7 @@
* uuencodebegin() no longer static
*
*/
static char const rcsid[] = "$Id: message.c,v 1.130 2004/12/14 10:27:57 nigelhorne Exp $";
static char const rcsid[] = "$Id: message.c,v 1.131 2004/12/14 16:45:43 nigelhorne Exp $";
#if HAVE_CONFIG_H
#include "clamav-config.h"
@ -458,10 +461,10 @@ static int simil(const char *str1, const char *str2);
static const struct encoding_map {
const char *string;
encoding_type type;
} encoding_map[] = { /* rfc1521 */
} encoding_map[] = { /* rfc2045 */
{ "7bit", NOENCODING },
{ "text/plain", NOENCODING },
{ "quoted-printable", QUOTEDPRINTABLE }, /* rfc1521 */
{ "quoted-printable", QUOTEDPRINTABLE }, /* rfc2045 */
{ "base64", BASE64 }, /* rfc2045 */
{ "8bit", EIGHTBIT },
{ "binary", BINARY },
@ -810,7 +813,7 @@ messageAddArguments(message *m, const char *s)
data = strchr(string, '=');
/*
* Some spam breaks RFC1521 by using ':' instead of '='
* Some spam breaks RFC2045 by using ':' instead of '='
* e.g.:
* Content-Type: text/html; charset:ISO-8859-1
* should be:
@ -837,7 +840,7 @@ messageAddArguments(message *m, const char *s)
/*
* Handle white space to the right of the equals sign
* This breaks RFC1521 which has:
* This breaks RFC2045 which has:
* parameter := attribute "=" value
* attribute := token ; case-insensitive
* token := 1*<any (ASCII) CHAR except SPACE, CTLs,
@ -1785,7 +1788,7 @@ messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy
}
/*
* According to RFC1521, '=' is used to pad out
* According to RFC2045, '=' is used to pad out
* the last byte and should be used as evidence
* of the end of the data. Some mail clients
* annoyingly then put plain text after the '='
@ -2178,11 +2181,23 @@ decodeLine(message *m, encoding_type et, const char *line, unsigned char *buf, s
break;
}
#if 0
/*
* Section 5.1 of RFC1521 states that any number of white
* Section 5.1 of RFC2045 states that any number of white
* space characters may appear on the end of the line
* before the final '=' which indicates a soft break.
*
* Section 6.7.(3) of RFC2045 is no clearer.
*
* This means that we have to do a look ahead here.
*
* This is a real pain because not everyone is
* aware of the implication of the above sentence,
* namely that you must encode any white space before
* the final '=' to ensure it is correctly transfered
* otherwise it is dropped.
* This code adheres to the RFC, but I don't think most
* other software does so I may have to change it
*/
p2 = strchr(line, '\0');
if(p2 == line) { /* empty line */
@ -2216,7 +2231,7 @@ decodeLine(message *m, encoding_type et, const char *line, unsigned char *buf, s
if((*++line == '\0') || (*line == '\n')) {
/*
* broken e-mail, not
* adhering to RFC1521
* adhering to RFC2045
*/
*buf++ = byte;
break;
@ -2229,6 +2244,37 @@ decodeLine(message *m, encoding_type et, const char *line, unsigned char *buf, s
*buf++ = *line;
line++;
}
#else
softbreak = FALSE;
while(*line) {
if(*line == '=') {
unsigned char byte;
if((*++line == '\0') || (*line == '\n')) {
softbreak = TRUE;
/* soft line break */
break;
}
byte = hex(*line);
if((*++line == '\0') || (*line == '\n')) {
/*
* broken e-mail, not
* adhering to RFC2045
*/
*buf++ = byte;
break;
}
byte <<= 4;
byte += hex(*line);
*buf++ = byte;
} else
*buf++ = *line;
line++;
}
#endif
if(!softbreak)
/* Put the new line back in */
*buf++ = '\n';
@ -2238,7 +2284,7 @@ decodeLine(message *m, encoding_type et, const char *line, unsigned char *buf, s
if(line == NULL)
break;
/*
* RFC1521 sets the maximum length to 76 bytes
* RFC2045 sets the maximum length to 76 bytes
* but many e-mail clients ignore that
*/
copy = strdup(line);
@ -2531,7 +2577,7 @@ hex(char c)
cli_dbgmsg("Illegal hex character '%c'\n", c);
/*
* Some mails (notably some spam) break RFC1521 by failing to encode
* Some mails (notably some spam) break RFC2045 by failing to encode
* the '=' character
*/
return '=';

Loading…
Cancel
Save