125 lines
3.6 KiB
Diff
125 lines
3.6 KiB
Diff
rom 39a33fcac0e4530ef0c60d3319504e078ea2f137 Mon Sep 17 00:00:00 2001
|
|
From: Daniel Stenberg <daniel@haxx.se>
|
|
Date: Mon, 8 May 2023 00:14:33 +0200
|
|
Subject: [PATCH] tool_operate: refuse (--data or --form) and --continue-at
|
|
combo
|
|
|
|
libcurl assumes that a --continue-at resumption is done to continue an
|
|
upload using the read callback and neither --data nor --form use
|
|
that and thus won't do what the user wants. Whatever the user wants
|
|
with this strange combination.
|
|
|
|
Add test 426 to verify.
|
|
|
|
Reported-by: Smackd0wn on github
|
|
Fixes #11081
|
|
Closes #11083
|
|
|
|
Conflict: context adapt for tests/data/Makefile.inc
|
|
Reference: https://github.com/curl/curl/commit/39a33fcac0e4530ef0c60d3319504e078ea2f137
|
|
---
|
|
src/tool_operate.c | 27 +++++++++++++++++++--------
|
|
tests/data/Makefile.inc | 1 +
|
|
tests/data/test426 | 34 ++++++++++++++++++++++++++++++++++
|
|
3 files changed, 54 insertions(+), 8 deletions(-)
|
|
create mode 100644 tests/data/test426
|
|
|
|
diff --git a/src/tool_operate.c b/src/tool_operate.c
|
|
index a9f93ef..c97addc 100644
|
|
--- a/src/tool_operate.c
|
|
+++ b/src/tool_operate.c
|
|
@@ -1310,19 +1310,30 @@ static CURLcode single_transfer(struct GlobalConfig *global,
|
|
|
|
switch(config->httpreq) {
|
|
case HTTPREQ_SIMPLEPOST:
|
|
- my_setopt_str(curl, CURLOPT_POSTFIELDS,
|
|
- config->postfields);
|
|
- my_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE,
|
|
- config->postfieldsize);
|
|
+ if(config->resume_from) {
|
|
+ errorf(global, "cannot mix --continue-at with --data\n");
|
|
+ result = CURLE_FAILED_INIT;
|
|
+ }
|
|
+ else {
|
|
+ my_setopt_str(curl, CURLOPT_POSTFIELDS,
|
|
+ config->postfields);
|
|
+ my_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE,
|
|
+ config->postfieldsize);
|
|
+ }
|
|
break;
|
|
case HTTPREQ_MIMEPOST:
|
|
/* free previous remainders */
|
|
curl_mime_free(config->mimepost);
|
|
config->mimepost = NULL;
|
|
- result = tool2curlmime(curl, config->mimeroot, &config->mimepost);
|
|
- if(result)
|
|
- break;
|
|
- my_setopt_mimepost(curl, CURLOPT_MIMEPOST, config->mimepost);
|
|
+ if(config->resume_from) {
|
|
+ errorf(global, "cannot mix --continue-at with --form\n");
|
|
+ result = CURLE_FAILED_INIT;
|
|
+ }
|
|
+ else {
|
|
+ result = tool2curlmime(curl, config->mimeroot, &config->mimepost);
|
|
+ if(!result)
|
|
+ my_setopt_mimepost(curl, CURLOPT_MIMEPOST, config->mimepost);
|
|
+ }
|
|
break;
|
|
default:
|
|
break;
|
|
diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc
|
|
index d681f92..2d62a6b 100644
|
|
--- a/tests/data/Makefile.inc
|
|
+++ b/tests/data/Makefile.inc
|
|
@@ -68,6 +68,7 @@ test392 test393 test394 test395 test396 test397 \
|
|
test400 test401 test402 test403 test404 test405 test406 test407 test408 \
|
|
test409 test410 \
|
|
test418 \
|
|
+test426 \
|
|
test430 test431 test432 test433 test434 test435 test445 test446\
|
|
\
|
|
test442 test443 test444 \
|
|
diff --git a/tests/data/test426 b/tests/data/test426
|
|
new file mode 100644
|
|
index 0000000..34c80c6
|
|
--- /dev/null
|
|
+++ b/tests/data/test426
|
|
@@ -0,0 +1,34 @@
|
|
+<testcase>
|
|
+<info>
|
|
+<keywords>
|
|
+error detection
|
|
+</keywords>
|
|
+</info>
|
|
+
|
|
+#
|
|
+# Server-side
|
|
+<reply>
|
|
+</reply>
|
|
+
|
|
+#
|
|
+# Client-side
|
|
+<client>
|
|
+<server>
|
|
+http
|
|
+</server>
|
|
+<name>
|
|
+try --data with --continue-at
|
|
+</name>
|
|
+<command>
|
|
+http://%HOSTIP:%HTTPPORT/%TESTNUMBER -d foobar -C 3
|
|
+</command>
|
|
+</client>
|
|
+
|
|
+#
|
|
+# Verify data after the test has been "shot"
|
|
+<verify>
|
|
+<errorcode>
|
|
+2
|
|
+</errorcode>
|
|
+</verify>
|
|
+</testcase>
|
|
--
|
|
2.33.0
|
|
|