aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPatrick Monnerat <Patrick.Monnerat@datasphere.ch>2007-10-18 10:54:49 +0000
committerPatrick Monnerat <Patrick.Monnerat@datasphere.ch>2007-10-18 10:54:49 +0000
commit8f5909b6648ed2833418827241805fa4eaa609f2 (patch)
treec5d1a079800ace35839307ae89ccfd4d634fbd78 /lib
parentbef2e7f2ff93902a34d999e1ede75ba4f9aabcd0 (diff)
Allow CURLOPT_COPYPOSTFIELDS with explicit data size = 0
Diffstat (limited to 'lib')
-rw-r--r--lib/url.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/url.c b/lib/url.c
index 373fd4534..6f6d8c226 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -1036,10 +1036,10 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
result = Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], argptr);
else {
/*
- * Check that request length does not overflow the size_t type.
+ * Check that requested length does not overflow the size_t type.
*/
- if ((data->set.postfieldsize < 1) ||
+ if ((data->set.postfieldsize < 0) ||
((sizeof(curl_off_t) != sizeof(size_t)) &&
(data->set.postfieldsize > (curl_off_t)((size_t)-1))))
result = CURLE_OUT_OF_MEMORY;
@@ -1047,14 +1047,22 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
char * p;
(void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
- p = malloc(data->set.postfieldsize);
+
+ /* Allocate even when size == 0. This satisfies the need of possible
+ later address compare to detect the COPYPOSTFIELDS mode, and
+ to mark that postfields is used rather than read function or
+ form data.
+ */
+ p = malloc(data->set.postfieldsize? data->set.postfieldsize: 1);
if (!p)
result = CURLE_OUT_OF_MEMORY;
else {
- memcpy(p, argptr, data->set.postfieldsize);
+ if (data->set.postfieldsize)
+ memcpy(p, argptr, data->set.postfieldsize);
+
data->set.str[STRING_COPYPOSTFIELDS] = p;
- }
+ }
}
}