Mailing List Archive

svn commit: r423021 - /spamassassin/branches/3.1/spamc/libspamc.c
Author: jm
Date: Tue Jul 18 02:20:14 2006
New Revision: 423021

URL: http://svn.apache.org/viewvc?rev=423021&view=rev
Log:
bug 4966: fix major BSMTP bug, which rendered SA unusable with exim4 when BSMTP is used. fix thanks to anomie

Modified:
spamassassin/branches/3.1/spamc/libspamc.c

Modified: spamassassin/branches/3.1/spamc/libspamc.c
URL: http://svn.apache.org/viewvc/spamassassin/branches/3.1/spamc/libspamc.c?rev=423021&r1=423020&r2=423021&view=diff
==============================================================================
--- spamassassin/branches/3.1/spamc/libspamc.c (original)
+++ spamassassin/branches/3.1/spamc/libspamc.c Tue Jul 18 02:20:14 2006
@@ -566,20 +566,20 @@
}

/* Find the end-of-DATA line */
- /* if bad format with no end ".\n" will truncate the last two characters of the buffer */
prev = '\n';
- for (i = j = 0; (i+2) < (unsigned int) m->msg_len; i++) { /* (i+2) prevents out of bound reference msg[i+2] */
+ for (i = j = 0; i < (unsigned int) m->msg_len; i++) {
if (prev == '\n' && m->msg[i] == '.') {
/* Dot at the beginning of a line */
- if ((m->msg[i + 1] == '\r' && m->msg[i + 2] == '\n')
- || m->msg[i + 1] == '\n') {
+ if (((i+1) == m->msg_len)
+ || ((i+1) < m->msg_len && m->msg[i + 1] == '\n')
+ || ((i+2) < m->msg_len && m->msg[i + 1] == '\r' && m->msg[i + 2] == '\n')) {
/* Lone dot! That's all, folks */
m->post = m->msg + i;
m->post_len = m->msg_len - i;
m->msg_len = j;
break;
}
- else if (m->msg[i + 1] == '.') {
+ else if ((i+1) < m->msg_len && m->msg[i + 1] == '.') {
/* Escaping dot, eliminate. */
prev = '.';
continue;
@@ -589,6 +589,9 @@
m->msg[j++] = m->msg[i];
}

+ /* if bad format with no end "\n.\n", error out */
+ if (m->post == NULL)
+ return EX_DATAERR;
m->type = MESSAGE_BSMTP;
m->out = m->msg;
m->out_len = m->msg_len;