diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2001-08-03 18:12:27 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2001-08-03 18:12:27 +0000 |
commit | 87426e377fe64a2c0564726799c60f69dc10dfee (patch) | |
tree | 1aa12ebf4d0647a512d56ab85f25cf54bc250bae | |
parent | 55ad985b7c30776293ccae7ecaffbc3c75cd7f69 (diff) | |
download | fetchmail-87426e377fe64a2c0564726799c60f69dc10dfee.tar.gz fetchmail-87426e377fe64a2c0564726799c60f69dc10dfee.tar.bz2 fetchmail-87426e377fe64a2c0564726799c60f69dc10dfee.zip |
Justin Guyett's fix.
svn path=/trunk/; revision=3436
-rw-r--r-- | driver.c | 9 | ||||
-rw-r--r-- | imap.c | 19 |
2 files changed, 25 insertions, 3 deletions
@@ -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 */ @@ -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) |