[PATCH] vtls: revert "receive max buffer" + add test case
authorStefan Eissing <stefan@eissing.org>
Thu, 1 Feb 2024 17:15:50 +0000 (18:15 +0100)
committerSamuel Henrique <samueloph@debian.org>
Mon, 19 Feb 2024 22:16:17 +0000 (22:16 +0000)
- add test_05_04 for requests using http/1.0, http/1.1 and h2 against an
  Apache resource that does an unclean TLS shutdown.
- revert special workarund in openssl.c for suppressing shutdown errors
  on multiplexed connections
- vlts.c restore to its state before 9a90c9dd64d2f03601833a70786d485851bd1b53

Fixes #12885
Fixes #12844

Closes #12848

Backported by Samuel Henrique <samueloph@debian.org>
  * Removed changes to files under tests/http/ which we don't have in our
    tarball.

Gbp-Pq: Name vtls_revert_receive_max_buffer_add_test_case.patch

lib/vtls/vtls.c

index e928ba5d079e6e3fb44cdff47c5503847ace8f7b..f654a9749cd258a5f0a8e93b035081fc7e081140 100644 (file)
@@ -1715,32 +1715,17 @@ static ssize_t ssl_cf_recv(struct Curl_cfilter *cf,
 {
   struct cf_call_data save;
   ssize_t nread;
-  size_t ntotal = 0;
 
   CF_DATA_SAVE(save, cf, data);
   *err = CURLE_OK;
-  /* Do receive until we fill the buffer somehwhat or EGAIN, error or EOF */
-  while(!ntotal || (len - ntotal) > (4*1024)) {
+  nread = Curl_ssl->recv_plain(cf, data, buf, len, err);
+  if(nread > 0) {
+    DEBUGASSERT((size_t)nread <= len);
+  }
+  else if(nread == 0) {
+    /* eof */
     *err = CURLE_OK;
-    nread = Curl_ssl->recv_plain(cf, data, buf + ntotal, len - ntotal, err);
-    if(nread < 0) {
-      if(*err == CURLE_AGAIN && ntotal > 0) {
-        /* we EAGAINed after having reed data, return the success amount */
-        *err = CURLE_OK;
-        break;
-      }
-      /* we have a an error to report */
-      goto out;
-    }
-    else if(nread == 0) {
-      /* eof */
-      break;
-    }
-    ntotal += (size_t)nread;
-    DEBUGASSERT((size_t)ntotal <= len);
   }
-  nread = (ssize_t)ntotal;
-out:
   CURL_TRC_CF(data, cf, "cf_recv(len=%zu) -> %zd, %d", len,
               nread, *err);
   CF_DATA_RESTORE(cf, save);