From: Steve Holme Date: Sun, 8 Sep 2013 09:30:43 +0000 (+0100) Subject: imap: Fixed calculation of transfer when partial FETCH received X-Git-Tag: curl-7_33_0~129 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e20e48cbf2a93c0fba7b0018f37de2cacd4df19f;p=thirdparty%2Fcurl.git imap: Fixed calculation of transfer when partial FETCH received The transfer size would be calculated incorrectly if the email contained within the FETCH response, had been partially received by the pingpong layer. As such the following, example output, would be seen if the amount remaining was smaller than the amount received: * Excess found in a non pipelined read: excess = 1394, size = 262, maxdownload = 262, bytecount = 1374 * transfer closed with -1112 bytes remaining to read Bug: http://curl.haxx.se/mail/lib-2013-08/0170.html Reported-by: John Dunn --- diff --git a/lib/imap.c b/lib/imap.c index 2207087850..17e9eb0b03 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -1465,10 +1465,10 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, int imapcode, return result; data->req.bytecount += chunk; - size -= chunk; infof(data, "Written %" FORMAT_OFF_TU " bytes, %" FORMAT_OFF_TU - " bytes are left for transfer\n", (curl_off_t)chunk, size); + " bytes are left for transfer\n", (curl_off_t)chunk, + size - chunk); /* Have we used the entire cache or just part of it?*/ if(pp->cache_size > chunk) { @@ -1485,7 +1485,7 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, int imapcode, } } - if(!size) + if(data->req.bytecount == size) /* The entire data is already transferred! */ Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL); else {