From a096f054c1ec695e8a23c5cbcdcb07d7d45c6495 Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Wed, 9 Nov 2005 23:54:56 +0000 Subject: When eating message trailer, don't see any line containing "OK" as the end of the trailer, but wait for the proper tagged OK line. To work around the qmail + Courier-IMAP problem in Debian Bug#338007. svn path=/trunk/; revision=4396 --- NEWS | 3 +++ imap.c | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index ec8e5efa..feabf655 100644 --- a/NEWS +++ b/NEWS @@ -264,6 +264,9 @@ fetchmail 6.3.0 (not yet released officially): Bug#320645. Matthias Andree * fetchmail.man: Fix Debian Bug#241883, making global options more clear. Matt Swift, Matthias Andree. +* When eating IMAP message trailer, don't see any line containing "OK" as the + end of the trailer, but wait for the proper tagged OK line. To work around + the qmail + Courier-IMAP problem in Debian Bug#338007. Matthias Andree # INTERNAL CHANGES * Switched to automake. Matthias Andree. diff --git a/imap.c b/imap.c index 00955946..3226f59d 100644 --- a/imap.c +++ b/imap.c @@ -1039,7 +1039,7 @@ static int imap_fetch_body(int sock, struct query *ctl, int number, int *lenp) return(PS_SUCCESS); } -static int imap_trail(int sock, struct query *ctl, int number) +static int imap_trail(int sock, struct query *ctl, int number, const char *tag) /* discard tail of FETCH response after reading message text */ { /* expunges change the fetch numbers */ @@ -1047,15 +1047,18 @@ static int imap_trail(int sock, struct query *ctl, int number) for (;;) { - char buf[MSGBUFSIZE+1]; + char buf[MSGBUFSIZE+1], *t; int ok; if ((ok = gen_recv(sock, buf, sizeof(buf)))) return(ok); /* UW IMAP returns "OK FETCH", Cyrus returns "OK Completed" */ - if (strstr(buf, "OK")) - break; + if (strncmp(buf, tag, strlen(tag)) == 0) { + t = buf + strspn(t, " \t"); + if (strncmp(t, "OK", 2)) + break; + } } return(PS_SUCCESS); -- cgit v1.2.3