diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2006-05-12 01:27:39 +0000 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2006-05-12 01:27:39 +0000 |
commit | 394b5392352b68b170e1ca37be6b5efadf256d07 (patch) | |
tree | 9cee7a32bb586a7a65846044d4d23c4a7cfd6cb9 | |
parent | 52a4e2437c5043a771b29a601abb1ed4413997a6 (diff) | |
download | fetchmail-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-- | NEWS | 6 | ||||
-rw-r--r-- | transact.c | 17 |
2 files changed, 23 insertions, 0 deletions
@@ -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) @@ -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 */ |