aboutsummaryrefslogtreecommitdiffstats
path: root/mail/fetchmail
diff options
context:
space:
mode:
authorbarner <barner@FreeBSD.org>2005-11-14 19:48:53 +0800
committerbarner <barner@FreeBSD.org>2005-11-14 19:48:53 +0800
commitb6e1d835eb0ae25e3236b9f21075d4655e550c92 (patch)
tree1b414cb70e1f62072393a2e34a6117123469e268 /mail/fetchmail
parent551bf7ae80aeff3732539b6f8d6e9f34864d6602 (diff)
downloadfreebsd-ports-gnome-b6e1d835eb0ae25e3236b9f21075d4655e550c92.tar.gz
freebsd-ports-gnome-b6e1d835eb0ae25e3236b9f21075d4655e550c92.tar.zst
freebsd-ports-gnome-b6e1d835eb0ae25e3236b9f21075d4655e550c92.zip
- Fix a bug introduced with fetchmail-6.2.5.2_3, where it would sometimes
leave some messages on an IMAP server, i.e. this is the correct fix for the following bug (as described Makefile:1.161 and files/patch-imap.c:1.1): fix IMAP client timeout bug with upstream servers that do not send updated EXISTS counts after acknowledging EXPUNGE see <http://bugs.debian.org/314509> - Bump PORTREVISION to 4 PR: ports/88850 Submitted by: Vasil Dimov Patch provided by: Matthias Andree (upstream maintainer) Patch tested by: barner, Vasil Dimov
Diffstat (limited to 'mail/fetchmail')
-rw-r--r--mail/fetchmail/Makefile2
-rw-r--r--mail/fetchmail/files/patch-imap.c164
2 files changed, 148 insertions, 18 deletions
diff --git a/mail/fetchmail/Makefile b/mail/fetchmail/Makefile
index 90189fff199b..2b16a7150a15 100644
--- a/mail/fetchmail/Makefile
+++ b/mail/fetchmail/Makefile
@@ -11,7 +11,7 @@
PORTNAME= fetchmail
PORTVERSION= 6.2.5.2
-PORTREVISION= 3
+PORTREVISION= 4
CATEGORIES= mail ipv6
MASTER_SITES= http://download.berlios.de/%SUBDIR%/:fetchmail_site,fetchmailconf_site \
http://www.catb.org/~esr/%SUBDIR%/:fetchmail_site \
diff --git a/mail/fetchmail/files/patch-imap.c b/mail/fetchmail/files/patch-imap.c
index 55347c15c2fe..d23575443e9f 100644
--- a/mail/fetchmail/files/patch-imap.c
+++ b/mail/fetchmail/files/patch-imap.c
@@ -1,18 +1,148 @@
---- ./imap.c.orig 2003-10-15 21:17:41.000000000 +0200
-+++ ./imap.c 2005-10-29 15:19:58.000000000 +0200
-@@ -105,6 +105,15 @@
- {
- recentcount = atoi(buf+2);
- }
-+ /* servers are not required to update the EXISTS counts,
-+ * so count down by ourselves */
-+ else if (strstr(buf, " EXPUNGE"))
-+ {
-+ if (atoi(buf+2) > 0) {
-+ if (count > 0)
-+ count --;
+Index: imap.c
+===================================================================
+--- imap.c (revision 4423)
++++ imap.c (working copy)
+@@ -57,72 +57,85 @@
+ *cp = toupper(*cp);
+
+ /* interpret untagged status responses */
+- if (strstr(buf, "* CAPABILITY"))
+- {
+- strncpy(capabilities, buf + 12, sizeof(capabilities));
+- capabilities[sizeof(capabilities)-1] = '\0';
+- }
+- else if (strstr(buf, "EXISTS"))
+- {
+- count = atoi(buf+2);
+- /*
+- * Don't trust the message count passed by the server.
+- * Without this check, it might be possible to do a
+- * DNS-spoofing attack that would pass back a ridiculous
+- * count, and allocate a malloc area that would overlap
+- * a portion of the stack.
+- */
+- if (count > INT_MAX/sizeof(int))
++ if (buf[0] == '*' && buf[1] == ' ') {
++ if (strstr(buf, " CAPABILITY"))
+ {
+- report(stderr, "bogus message count!");
+- return(PS_PROTOCOL);
++ strncpy(capabilities, buf + 12, sizeof(capabilities));
++ capabilities[sizeof(capabilities)-1] = '\0';
+ }
+-
+- /*
+- * Nasty kluge to handle RFC2177 IDLE. If we know we're idling
+- * we can't wait for the tag matching the IDLE; we have to tell the
+- * server the IDLE is finished by shipping back a DONE when we
+- * see an EXISTS. Only after that will a tagged response be
+- * shipped. The idling flag also gets cleared on a timeout.
+- */
+- if (stage == STAGE_IDLE)
++ else if (strstr(buf, " EXISTS"))
+ {
+- /* If IDLE isn't supported, we were only sending NOOPs anyway. */
+- if (has_idle)
++ count = atoi(buf+2);
++ /*
++ * Don't trust the message count passed by the server.
++ * Without this check, it might be possible to do a
++ * DNS-spoofing attack that would pass back a ridiculous
++ * count, and allocate a malloc area that would overlap
++ * a portion of the stack.
++ */
++ if (count > INT_MAX/sizeof(int))
+ {
+- /* we do our own write and report here to disable tagging */
+- SockWrite(sock, "DONE\r\n", 6);
+- if (outlevel >= O_MONITOR)
+- report(stdout, "IMAP> DONE\n");
++ report(stderr, "bogus message count!");
++ return(PS_PROTOCOL);
+ }
+
+- mytimeout = saved_timeout;
+- stage = STAGE_FETCH;
++ /*
++ * Nasty kluge to handle RFC2177 IDLE. If we know we're idling
++ * we can't wait for the tag matching the IDLE; we have to tell the
++ * server the IDLE is finished by shipping back a DONE when we
++ * see an EXISTS. Only after that will a tagged response be
++ * shipped. The idling flag also gets cleared on a timeout.
++ */
++ if (stage == STAGE_IDLE)
++ {
++ /* If IDLE isn't supported, we were only sending NOOPs anyway. */
++ if (has_idle)
++ {
++ /* we do our own write and report here to disable tagging */
++ SockWrite(sock, "DONE\r\n", 6);
++ if (outlevel >= O_MONITOR)
++ report(stdout, "IMAP> DONE\n");
++ }
++
++ mytimeout = saved_timeout;
++ stage = STAGE_FETCH;
++ }
+ }
++ /* a space is required to avoid confusion with the \Recent flag */
++ else if (strstr(buf, " RECENT"))
++ {
++ recentcount = atoi(buf+2);
++ }
++ /* servers are not required to update the EXISTS counts,
++ * so count down by ourselves */
++ else if (strstr(buf, " EXPUNGE"))
++ {
++ if (atoi(buf+2) > 0) {
++ if (count > 0)
++ count --;
++ }
++ }
++ else if (strstr(buf, " PREAUTH")) {
++ preauth = TRUE;
+ }
-+ }
- else if (strstr(buf, "PREAUTH"))
- preauth = TRUE;
- /*
++ /*
++ * The server may decide to make the mailbox read-only,
++ * which causes fetchmail to go into a endless loop
++ * fetching the same message over and over again.
++ *
++ * However, for check_only, we use EXAMINE which will
++ * mark the mailbox read-only as per the RFC.
++ *
++ * This checks for the condition and aborts if
++ * the mailbox is read-only.
++ *
++ * See RFC 2060 section 6.3.1 (SELECT).
++ * See RFC 2060 section 6.3.2 (EXAMINE).
++ */
++ else if (!check_only && strstr(buf, "[READ-ONLY]")) {
++ return(PS_LOCKBUSY);
++ }
+ }
+- /* a space is required to avoid confusion with the \Recent flag */
+- else if (strstr(buf, " RECENT"))
+- {
+- recentcount = atoi(buf+2);
+- }
+- else if (strstr(buf, "PREAUTH"))
+- preauth = TRUE;
+- /*
+- * The server may decide to make the mailbox read-only,
+- * which causes fetchmail to go into a endless loop
+- * fetching the same message over and over again.
+- *
+- * However, for check_only, we use EXAMINE which will
+- * mark the mailbox read-only as per the RFC.
+- *
+- * This checks for the condition and aborts if
+- * the mailbox is read-only.
+- *
+- * See RFC 2060 section 6.3.1 (SELECT).
+- * See RFC 2060 section 6.3.2 (EXAMINE).
+- */
+- else if (!check_only && strstr(buf, "[READ-ONLY]"))
+- return(PS_LOCKBUSY);
+ } while
+ (tag[0] != '\0' && strncmp(buf, tag, strlen(tag)));
+