]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_operate: refuse (--data or --form) and --continue-at combo
authorDaniel Stenberg <daniel@haxx.se>
Sun, 7 May 2023 22:14:33 +0000 (00:14 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 8 May 2023 12:10:44 +0000 (14:10 +0200)
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

src/tool_operate.c
tests/data/Makefile.inc
tests/data/test426 [new file with mode: 0644]

index 06ae39396cc0b4f542fca60201658b33c646d253..4da9dea16d59cbabf9baa706bbeacd8ce59fe9ee 100644 (file)
@@ -1398,19 +1398,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;
index 8baf721b70cdac500583ec4bad582483e5ced16c..c2d9cb2a26d9717345dcd9df6a368b19addfc8ba 100644 (file)
@@ -69,7 +69,7 @@ test390 test391 test392 test393 test394 test395 test396 test397 test398 \
 test399 test400 test401 test402 test403 test404 test405 test406 test407 \
 test408 test409 test410 test411 test412 test413 test414 test415 test416 \
 test417 test418 test419 test420 test421 test422 test423 test424 test425 \
-\
+test426 \
 test430 test431 test432 test433 test434 test435 test436 \
 \
 test440 test441 test442 test443 test444 test445 test446 \
diff --git a/tests/data/test426 b/tests/data/test426
new file mode 100644 (file)
index 0000000..34c80c6
--- /dev/null
@@ -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>