summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-01-15 00:11:33 +0100
committerDaniel Stenberg <daniel@haxx.se>2020-01-15 00:14:46 +0100
commit7c325972dc82f8ca8f493c6afe335810e7158547 (patch)
tree5c2e839a5fedba41443d725bfdb1e0eca0b889eb
parentbe578eea7e4d97a3c74fc7e1341ee258925e08ff (diff)
downloadcurl-bagder/mime-callback-abort.tar.gz
mime: return CURL_READFUNC_ABORT back to parentbagder/mime-callback-abort
When *ABORT is returned from the callback, the transfer must stop immediately and the return code must be passed back to the parent all the way up to Curl_fillreadbuffer(). Test 644 was supposed to verify this but it wasn't done right. Now it makes sure the callback is never called again after CURL_READFUNC_ABORT is returned and it also makes sure the data transfer is actually stopped as instructed. Also removed the 'flaky' keyword since the test is now modified. Fixes #4813 Reported-by: MrdUkk on github
-rw-r--r--lib/mime.c10
-rw-r--r--tests/data/test6444
-rw-r--r--tests/libtest/lib643.c7
3 files changed, 13 insertions, 8 deletions
diff --git a/lib/mime.c b/lib/mime.c
index 081e51e50..fe005a1e8 100644
--- a/lib/mime.c
+++ b/lib/mime.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -765,6 +765,7 @@ static size_t read_encoded_part_content(curl_mimepart *part,
break;
case CURL_READFUNC_ABORT:
case CURL_READFUNC_PAUSE:
+ return sz;
case READ_ERROR:
return cursize? cursize: sz;
default:
@@ -794,6 +795,7 @@ static size_t read_encoded_part_content(curl_mimepart *part,
break;
case CURL_READFUNC_ABORT:
case CURL_READFUNC_PAUSE:
+ return sz;
case READ_ERROR:
return cursize? cursize: sz;
default:
@@ -878,10 +880,11 @@ static size_t readback_part(curl_mimepart *part,
part->fp = NULL;
}
/* FALLTHROUGH */
- case CURL_READFUNC_ABORT:
- case CURL_READFUNC_PAUSE:
case READ_ERROR:
return cursize? cursize: sz;
+ case CURL_READFUNC_ABORT:
+ case CURL_READFUNC_PAUSE:
+ return sz;
}
break;
case MIMESTATE_END:
@@ -966,6 +969,7 @@ static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems,
switch(sz) {
case CURL_READFUNC_ABORT:
case CURL_READFUNC_PAUSE:
+ return sz;
case READ_ERROR:
return cursize? cursize: sz;
case 0:
diff --git a/tests/data/test644 b/tests/data/test644
index 4c9a501ed..dc515e32d 100644
--- a/tests/data/test644
+++ b/tests/data/test644
@@ -4,7 +4,6 @@
HTTP
HTTP POST
HTTP MIME POST
-flaky
</keywords>
</info>
@@ -47,9 +46,6 @@ Accept: */*
Content-Length: 718
Content-Type: multipart/form-data; boundary=----------------------------
-------------------------------
-Content-Disposition: form-data; name="sendfile"; filename="postit2.c"
-
</protocol>
# CURLE_ABORTED_BY_CALLBACK (42)
<errorcode>
diff --git a/tests/libtest/lib643.c b/tests/libtest/lib643.c
index 7432dfce8..047a9b384 100644
--- a/tests/libtest/lib643.c
+++ b/tests/libtest/lib643.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -41,10 +41,15 @@ struct WriteThis {
static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
{
#ifdef LIB644
+ static int count = 0;
(void)ptr;
(void)size;
(void)nmemb;
(void)userp;
+ if(++count > 1) {
+ printf("Wrongly called >1 times\n");
+ exit(1); /* trigger major failure */
+ }
return CURL_READFUNC_ABORT;
#else