aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Andree <matthias.andree@gmx.de>2006-05-12 01:27:39 +0000
committerMatthias Andree <matthias.andree@gmx.de>2006-05-12 01:27:39 +0000
commit394b5392352b68b170e1ca37be6b5efadf256d07 (patch)
tree9cee7a32bb586a7a65846044d4d23c4a7cfd6cb9
parent52a4e2437c5043a771b29a601abb1ed4413997a6 (diff)
downloadfetchmail-394b5392352b68b170e1ca37be6b5efadf256d07.tar.gz
fetchmail-394b5392352b68b170e1ca37be6b5efadf256d07.tar.bz2
fetchmail-394b5392352b68b170e1ca37be6b5efadf256d07.zip
For protocols such as IMAP that are not delimited by "." lines, truncate
the input buffer when the message has been completely read, to avoid taking trailing garbage into the message if the terminal CRLF is missing. Fixes Debian Bug#312415. (Patch suggested by Mike Jones, Manchester Univ.). svn path=/branches/BRANCH_6-3/; revision=4824
-rw-r--r--NEWS6
-rw-r--r--transact.c17
2 files changed, 23 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 070010b9..518dd940 100644
--- a/NEWS
+++ b/NEWS
@@ -50,6 +50,12 @@ fetchmail 6.3.5 (not yet released):
* fetchmail expects Received: headers in a particular format when parsing
envelopes.
+# BUG FIXES:
+* For protocols such as IMAP that are not delimited by "." lines, truncate the
+ input buffer when the message has been completely read, to avoid taking
+ trailing garbage into the message if the terminal CRLF is missing. Fixes
+ Debian Bug#312415. (Patch suggested by Mike Jones, Manchester Univ.).
+
# TRANSLATION UPDATES:
* Russian/ru (Pavel Maryanov), Vietnamese/vi (Clytie Siddall)
diff --git a/transact.c b/transact.c
index 66016d14..ba84f47d 100644
--- a/transact.c
+++ b/transact.c
@@ -1335,6 +1335,9 @@ int readbody(int sock, struct query *ctl, flag forward, int len)
while (protocol->delimited || len > 0)
{
set_timeout(mytimeout);
+ /* XXX FIXME: for undelimited protocols that ship the size, such
+ * as IMAP, we might want to use the count of remaining characters
+ * instead of the buffer size -- not for fetchmail 6.3.X though */
if ((linelen = SockRead(sock, inbufp, sizeof(buf)-4-(inbufp-buf)))==-1)
{
set_timeout(0);
@@ -1357,6 +1360,20 @@ int readbody(int sock, struct query *ctl, flag forward, int len)
sizeticker -= SIZETICKER;
}
}
+
+ /* Mike Jones, Manchester University, 2006:
+ * "To fix IMAP MIME Messages in which fetchmail adds the remainder of
+ * the IMAP packet including the ')' character (part of the IMAP)
+ * Protocol causing the addition of an extra MIME boundary locally."
+ *
+ * However, we shouldn't do this for delimited protocols:
+ * many POP3 servers (Microsoft, qmail) goof up message sizes
+ * so we might end truncating messages prematurely.
+ */
+ if (!protocol->delimited && linelen > len) {
+ inbufp[len] = '\0';
+ }
+
len -= linelen;
/* check for end of message */