aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2001-08-03 18:12:27 +0000
committerEric S. Raymond <esr@thyrsus.com>2001-08-03 18:12:27 +0000
commit87426e377fe64a2c0564726799c60f69dc10dfee (patch)
tree1aa12ebf4d0647a512d56ab85f25cf54bc250bae
parent55ad985b7c30776293ccae7ecaffbc3c75cd7f69 (diff)
downloadfetchmail-87426e377fe64a2c0564726799c60f69dc10dfee.tar.gz
fetchmail-87426e377fe64a2c0564726799c60f69dc10dfee.tar.bz2
fetchmail-87426e377fe64a2c0564726799c60f69dc10dfee.zip
Justin Guyett's fix.
svn path=/trunk/; revision=3436
-rw-r--r--driver.c9
-rw-r--r--imap.c19
2 files changed, 25 insertions, 3 deletions
diff --git a/driver.c b/driver.c
index 43772458..bc99d592 100644
--- a/driver.c
+++ b/driver.c
@@ -428,7 +428,14 @@ static int fetch_messages(int mailserver_socket, struct query *ctl,
/* request a message */
err = (ctl->server.base_protocol->fetch_headers)(mailserver_socket,ctl,num, &len);
- if (err != 0)
+ if (err == PS_TRANSIENT) /* server is probably Exchange */
+ {
+ report_build(stdout,
+ _("couldn't fetch headers, msg %d (%d octets)"),
+ num, msgsizes[num-1]);
+ continue;
+ }
+ else if (err != 0)
return(err);
/* -1 means we didn't see a size in the response */
diff --git a/imap.c b/imap.c
index 0adb7075..96ca7ee3 100644
--- a/imap.c
+++ b/imap.c
@@ -656,6 +656,14 @@ static int imap_is_old(int sock, struct query *ctl, int number)
return(seen);
}
+static char *skip_token(char *ptr)
+{
+ while(isspace(*ptr)) ptr++;
+ while(!isspace(*ptr) && !iscntrl(*ptr)) ptr++;
+ while(isspace(*ptr)) ptr++;
+ return(ptr);
+}
+
static int imap_fetch_headers(int sock, struct query *ctl,int number,int *lenp)
/* request headers of nth message */
{
@@ -675,11 +683,18 @@ static int imap_fetch_headers(int sock, struct query *ctl,int number,int *lenp)
for (;;)
{
int ok;
+ char *ptr;
if ((ok = gen_recv(sock, buf, sizeof(buf))))
return(ok);
- if (sscanf(buf+2, "%d FETCH (%*s {%d}", &num, lenp) == 2)
- break;
+ ptr = skip_token(buf); /* either "* " or "AXXXX " */
+ if (sscanf(ptr, "%d FETCH (%*s {%d}", &num, lenp) == 2)
+ break;
+ /* try to recover from chronically fucked-up M$ Exchange servers */
+ else if (!strncmp(ptr, "NO", 2))
+ return(PS_TRANSIENT);
+ else if (!strncmp(ptr, "BAD", 3))
+ return(PS_TRANSIENT);
}
if (num != number)