cURL / Mailing Lists / curl-library / Single Mail

curl-library

Problem with Curl_pop3_write() when data is received over multiple packets

From: Steve Holme <steve_holme_at_hotmail.com>
Date: Thu, 24 Nov 2011 17:46:19 +0000

Dear all,

 

I think I have found a problem with Curl_pop3_write() when receiving an
email and was wondered if anyone had any advice on how to fix the issue.

 

The problem has occurred by chance as I happen to have an email that is
15929 characters long and either my email server (Microsoft Exchange) and /
or the network layer of my PC is sending the email and terminating CRLF.CRLF
over two packets (15931 bytes in the first packet and 3 bytes in the
second). If one packet was to be received with all the data in it (15934
bytes) then the memcmp() for the CRLF.CRLF would succeed as it does for
smaller emails and the LIST command (assuming the results of the list
command aren't 15929 characters long as well).

 

As such, libcurl passes all of the first data chunk down to my write
function (rather than just the 15929 bytes of the email) and then the final
3 bytes in a second call to my write function after it has received the
second packet. Given this, libcurl never finishes the transfer as it then
loops round waiting for more data.

 

Whilst I happen to be receiving the first two bytes of the EOB at the end of
the first packet, I guess anything from 1 to 4 characters could be received
at the end of a chunk which would cause the compare to fail.

 

In addition to this, the existing code tries to cater for the EOB being sent
across 5 individual data chunks (as per the comment towards the top of this
function) but I don't believe this to be 100% correct either.

 

It might be best to completely rewrite this logic, similar to what Daniel
did with the EOB when sending SMTP emails but any recommendations / advise
would be appreciated as I don't fancy doing 4 extra memory compares.

 

Kind Regards

 

Steve

 

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-11-24