On Tue, 23 Jul 2013, Byrial Jensen wrote:
I have a problem with curl_formadd() which I suspect is a bug:
fails with CURLcode 2 (CURLE_FAILED_INIT) which I do not understand.
First, this is a minor mistake. curl_formadd() does not return the general
libcurl error code! It returns a CURLFORMcode and a 2 there equals
CURL_FORMADD_OPTION_TWICE ...
Is this a bug or did I do something wrong?
It is quite clearly a bug, and I've attached my suggested patch for fixing
this problem.
Comments?
--
/ daniel.haxx.se
From 8aebbcfa064f9a3a02b13ff5016eb526dc184c02 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <dan...@haxx.se>
Date: Tue, 23 Jul 2013 22:10:44 +0200
Subject: [PATCH] formadd: CURLFORM_FILECONTENT wrongly rejected some option
combos
The code for CURLFORM_FILECONTENT had its check for duplicate options
wrong so that it would reject CURLFORM_PTRNAME but not
CURLFORM_COPYNAME! The flags field used for this purpose cannot be
interpreted that broadly.
Bug: http://curl.haxx.se/mail/lib-2013-07/0258.html
Reported-by: Byrial Jensen
---
lib/formdata.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/formdata.c b/lib/formdata.c
index decb84d..1984a97 100644
--- a/lib/formdata.c
+++ b/lib/formdata.c
@@ -426,7 +426,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
/* Get contents from a given file name */
case CURLFORM_FILECONTENT:
- if(current_form->flags != 0)
+ if(current_form->flags & (HTTPPOST_PTRCONTENTS|HTTPPOST_READFILE))
return_value = CURL_FORMADD_OPTION_TWICE;
else {
const char *filename = array_state?
--
1.7.10.4
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html