cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: POSTing binary data doesn't work in 7.43.0

From: Stefan Bühler <buehler_at_teamviewer.com>
Date: Tue, 23 Jun 2015 16:27:36 +0200

Hi,

the trouble is related to multi handles, curl_multi_add_handle sets
infilesize:
    data->state.infilesize = data->set.postfieldsize;

If you first add the easy to the multi handle and then set the options
it won't work.

I just checked the curl_multi_add_handle docs, and it doesn't sound like
this isn't allowed.

Demo: I started with
https://raw.githubusercontent.com/bagder/curl/master/docs/examples/multi-app.c

Then I removed the FTP_HANDLE, and moved curl_easy_setopt after
curl_multi_add_handle, and also added new POST options with binary +
sized content; also used httpbin.org/post as URL.

I just updated my debian testing here, which got
libcurl4-gnutls-dev:amd64 7.43.0-1 this morning (I think), then:

$ gcc -o curl-multi-post-test curl-multi-post-test.c -O2 -lcurl
$ ./curl-multi-post-test
...
"form": { "\ufffdabc": "" },
"headers": { ... "Content-Length": "4", ... }
...

- the length should have been 8.

On 06/23/2015 03:28 PM, Daniel Stenberg wrote:
> On Mon, 22 Jun 2015, Stefan Bühler wrote:
>
>> we use CURLOPT_POSTFIELDSIZE_LARGE and CURLOPT_POSTFIELDS to set the
>> POST request body.
>>
>> With 7.43.0 it seems to ignore the size and to use strlen() instead
>> (i.e. it cuts the body after the first null byte).
>
> Maybe not that simple. I tried this little patch below on test 578,
> making sure that there is a binary zero in the middle of the POST data.
> However, this still works as supposed and no error is reported.
>
> Can you provide a simple stand-alone example that repeats the problem?
>
> diff --git a/tests/libtest/lib578.c b/tests/libtest/lib578.c
> index a39b317..3211c37 100644
> --- a/tests/libtest/lib578.c
> +++ b/tests/libtest/lib578.c
> @@ -22,11 +22,11 @@
> #include "test.h"
>
> #include "memdebug.h"
>
> /* The size of data should be kept below MAX_INITIAL_POST_SIZE! */
> -static char data[]="this is a short string.\n";
> +static char data[]="this is a short\0 string\n";
>
> static size_t data_size = sizeof(data) / sizeof(char);
>
> static int progress_callback(void *clientp, double dltotal, double
> dlnow, double ultotal, double ulnow)
> {

-- 
Best regards,
Stefan Bühler


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

Received on 2015-06-23