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
This commit is contained in:
Daniel Stenberg 2023-05-08 00:14:33 +02:00
parent fb7886b9c9
commit 39a33fcac0
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 54 additions and 9 deletions

View 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;