diff options
author | Steve Holme <steve_holme@hotmail.com> | 2012-02-18 22:57:13 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2012-02-19 23:48:14 +0100 |
commit | 035ef06bda7fbe9ae1934f9dee008b61ad623ac1 (patch) | |
tree | dea3642a8712bd92e6b5af281dcc645c4e128347 | |
parent | 3d98aed5b351b6437a6ffffed0589f8ab02a59e0 (diff) |
pop3.c: Fixed drop of final CRLF in EOB checking
Curl_pop3_write() would drop the final CRLF of a message as it was
considered part of the EOB as opposed to part of the message. Whilst
the EOB sequence needs to be searched for by the function only the
final 3 characters should be removed as per RFC-1939 section 3.
Reported by: Rich Gray
Bug: http://curl.haxx.se/mail/lib-2012-02/0051.html
-rw-r--r-- | lib/pop3.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/pop3.c b/lib/pop3.c index cc360b8b9..b9201e474 100644 --- a/lib/pop3.c +++ b/lib/pop3.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -755,7 +755,7 @@ static CURLcode pop3_done(struct connectdata *conn, CURLcode status, Curl_safefree(pop3c->mailbox); pop3c->mailbox = NULL; - /* clear these for next connection */ + /* Clear the transfer mode for the next connection */ pop3->transfer = FTPTRANSFER_BODY; return result; @@ -1035,7 +1035,7 @@ CURLcode Curl_pop3_write(struct connectdata *conn, char *str, size_t nread) { - /* This code could be made into a special function in the handler struct. */ + /* This code could be made into a special function in the handler struct */ CURLcode result = CURLE_OK; struct SessionHandle *data = conn->data; struct SingleRequest *k = &data->req; @@ -1131,10 +1131,15 @@ CURLcode Curl_pop3_write(struct connectdata *conn, } if(pop3c->eob == POP3_EOB_LEN) { - /* We have a full match so the transfer is done! */ + /* We have a full match so the transfer is done, however we must transfer + the CRLF at the start of the EOB as this is considered to be part of the + message as per RFC-1939, sect. 3 */ + result = Curl_client_write(conn, CLIENTWRITE_BODY, (char*)POP3_EOB, 2); + k->keepon &= ~KEEP_RECV; pop3c->eob = 0; - return CURLE_OK; + + return result; } if(pop3c->eob) |