cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: failed tests building curl 7.26

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 7 Jun 2012 22:28:10 +0200 (CEST)

On Thu, 7 Jun 2012, Neil Bowers wrote:

> The problem is the following code at line 148 of lib554.c
>
> formrc = curl_formadd(&formpost, &lastptr,
> CURLFORM_COPYNAME, "somename",
> CURLFORM_BUFFER, "somefile.txt",
> CURLFORM_BUFFERPTR, "blah blah",
> CURLFORM_BUFFERLENGTH, 9,
> CURLFORM_END);
>
> The two lines in red need to be switched, as the Curl_getformdata expects
> BUFFERLENGTH to be defined before you refer to BUFFERPTR. With this change
> curl 7.26 builds cleanly -- yippee!

No really no, that's not the _problem_. That's a work-around to hide the
problem from happening to you. The API for curl_formadd() allows them to be
added in that order so the function should be fixed to handle it.

I would rather suggest this, since CURLFORM_BUFFERLENGTH must be a long and
without an explicit type here it will be passed in as an int:

diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c
index d20429d..950cafc 100644
--- a/tests/libtest/lib554.c
+++ b/tests/libtest/lib554.c
@@ -149,7 +149,7 @@ int test(char *URL)
                          CURLFORM_COPYNAME, "somename",
                          CURLFORM_BUFFER, "somefile.txt",
                          CURLFORM_BUFFERPTR, "blah blah",
- CURLFORM_BUFFERLENGTH, 9,
+ CURLFORM_BUFFERLENGTH, (long)9,
                          CURLFORM_END);

    if(formrc)

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2012-06-07