From: Fabian Keil <fk@fabiankeil.de>
Date: Fri, 26 Mar 2021 13:14:12 +0000 (+0100)
Subject: receive_and_send_encrypted_post_data(): Additionally check for data being available
X-Git-Tag: v_3_0_34~128
X-Git-Url: http://www.privoxy.org/gitweb/%22https:/faq/@user-manual@?a=commitdiff_plain;h=4610ab9d9;p=privoxy.git

receive_and_send_encrypted_post_data(): Additionally check for data being available

Previously we relied on the TLS library reading more data from
the wire than we read in which case the is_ssl_pending() check
worked.

Sponsored by: Robert Klemme
---

diff --git a/jcc.c b/jcc.c
index 23679b53..c8367e54 100644
--- a/jcc.c
+++ b/jcc.c
@@ -2370,8 +2370,9 @@ static int receive_and_send_encrypted_post_data(struct client_state *csp)
 {
    int content_length_known = csp->expected_client_content_length != 0;
 
-   while (is_ssl_pending(&(csp->ssl_client_attr))
-      || (content_length_known && csp->expected_client_content_length != 0))
+   while ((content_length_known && csp->expected_client_content_length != 0) ||
+      (is_ssl_pending(&(csp->ssl_client_attr)) ||
+            data_is_available(csp->cfd, csp->config->socket_timeout)))
    {
       unsigned char buf[BUFFER_SIZE];
       int len;