aboutsummaryrefslogtreecommitdiffstats
path: root/imap.c
diff options
context:
space:
mode:
Diffstat (limited to 'imap.c')
-rw-r--r--imap.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/imap.c b/imap.c
index cfc85fa6..7ea1ef98 100644
--- a/imap.c
+++ b/imap.c
@@ -672,13 +672,19 @@ static int imap_fetch_headers(int sock, struct query *ctl,int number,int *lenp)
gen_send(sock, "FETCH %d RFC822.HEADER", number);
/* looking for FETCH response */
- do {
+ for (;;)
+ {
int ok;
if ((ok = gen_recv(sock, buf, sizeof(buf))))
return(ok);
- } while
- (sscanf(buf+2, "%d FETCH (%*s {%d}", &num, lenp) != 2);
+ if (sscanf(buf+2, "%d FETCH (%*s {%d}", &num, lenp) == 2)
+ break;
+ else if (sscanf(buf+2, "%d NO", &num) == 1)
+ return(PS_ERROR);
+ else if (sscanf(buf+2, "%d BAD", &num) == 1)
+ return(PS_ERROR);
+ }
if (num != number)
return(PS_ERROR);