cURL / Mailing Lists / curl-library / Single Mail

curl-library

Bug sending multipart emails with libcurl 7.22.0

From: Tristan Van Berkom <tristan_at_upstairslabs.com>
Date: Sun, 02 Mar 2014 20:23:44 +0900

I realize this is a fairly old version, however I have experienced a
bug sending multipart emails with this version and I went to the trouble
of providing a test case which can be used to reproduce the bug.

The bug occurs when curl's CURLOPT_READFUNCTION callback reports
more than the initial message header in the first callback, the
bug goes away if I report the initial header separate from the
following "part" header.

Here is an example of the broken data I get back in Evolution
mail client after sending the buggy message over smtp:

========================================================
Return-path: <mister_at_pony.com>
Envelope-to: tristan_at_upstairslabs.com
Delivery-date: Sun, 02 Mar 2014 04:32:46 -0500
Received: from [121.162.195.135] (port=49319 helo=tristan-N53SV) by
 beaubien.web-dns1.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim
 4.82) (envelope-from <mister_at_pony.com>) id 1WK2lD-00064t-CS for
 tristan_at_upstairslabs.com; Sun, 02 Mar 2014 04:32:44 -0500
Date: Sun, 02 Mar 2014 18:32:28 +0900
MIME-Version: 1.0
Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd_at_rfcpedant.example.org>
From: mister_at_pony.com
To: tristan_at_upstairslabs.com
Subject: Its a brand new test
Content-Type: multipart/related; boundary="a71d0c4efb77e4d74a363524d8e8bc20"
X-Evolution-Source: 1386230706.1972.22_at_tristan-N53SV

--a71d0c4efb77e4d74a363524d8e8bc20
Content-Type: text/html; format=flowed; charset=UTF-8
<html xmlns="http: //www.w3.org/1999/xhtml"> <head> <meta
 http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title>Untitled Document</title> </head> <body bgcolor="#F6CEEC"> <table
 width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <h1
 style="border-width: 1; border: solid; text-align: center; color:
 #8A084B;">Its a Pony !</h1> </tr> <tr> <td style="text-align: center;"> <p
 style="color: #088A29;">Once upon a pony, there was a pony on the ponyside,
 and every pony that the pony would take a pony or two, it was clear that
 the pony wanted to be the single poniest of the whole wide ponyverse.</p>
 <img src="cid:pony.jpg"/> </td> </tr> </table> <p>PS: How does this show up
 in your mail reader ?</p> </body>

--a71d0c4efb77e4d74a363524d8e8bc20
Content-Type: image/jpeg
Content-Disposition: inline; filename="pony.jpg"
Content-ID: <pony.jpg>
Content-Transfer-Encoding: base64

[ The rest of the message comes through fine ... ]
========================================================

Notice after the first boundary, an html message body is
intended to follow, it starts out alright:

--a71d0c4efb77e4d74a363524d8e8bc20
Content-Type: text/html; format=flowed; charset=UTF-8

But is missing the "\r\n" and is then followed by
a truncated and wrapping html body (note this doesnt
happen if the main message header is copied into curl's
buffer in one callback separate from the following callbacks).

The test case is based on this simple example:
   http://curl.haxx.se/libcurl/c/smtp-tls.html

You can try setting SEPARATE_HEADER_AND_BODY to 1
to test the proper functionality of the message, and
set it to 0 so that the main header is copied along
with the first "part" header.

I would be interested to know if this bug has been fixed
in more recent versions of libcurl - the test case should
be very easy to compile - on linux I can compile it with:

gcc -o curl-test-case curl-test-case.c `pkg-config --cflags --libs
libcurl`

It requires that curl-test-data.h be present in the same
directory as curl-test-case.c (of course).

Cheers,
    -Tristan

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html

Received on 2014-03-02