cURL / Mailing Lists / curl-library / Single Mail

curl-library

SMTP returns "read function returned funny values" for large attachments.

From: mwt Bigpond <mtrendle_at_bigpond.com>
Date: Mon, 22 Apr 2013 14:46:12 +1000

Hi,

I'm using libcurl C library, to build a fairly simple SMTP client to
send emails with any number of attachments. I expect the attachments
to be a reasonable size (less that 2 Mb) and I hold the MIME record
sequence in memory during the mailing process. I could change this if
necessary, and use a temporary file.

I have a read callback function, with CURLOPT_READFUNCTION and READDATA
options set in the email function.

Attaching any number of small files works fine. If I attach a larger
file (I think 16 Kb might be the limit) the program crashes with a Curl
message "read function returned funny values", immediately after the
base64 string containing the attached file has been returned to Curl
through the read callback.

INFILESIZE has been set to the total length of the MIME records. The
read callback returns the correct number of characters for each call,
including the last one that causes the crash.

During the read callback call to memcpy handling the big base64 string,
it seems that an "Invalid write of size 1" occurs, and one end of the
*bufptr or the other (it varies), followed by an "Invalid write of size
4" in curl_easy_perform. These errors do not occur sending smaller
files.

I've looked at BUFFERSIZE, but this appears to apply to write callbacks.
I've looked at transfer.c in libcurl where the message is generated, and
can't see any solution there. Searches on "read buffer size" don't
seem to help either.

Is there something simple that I've overlooked? I'd appreciate your
help.

Regards

Mark.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-04-22