summaryrefslogtreecommitdiffstats
path: root/debian/patches/fix-tls-1.3.patch
blob: e318b76af37f22167eacbcc2a291459878c01770 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Description: Fix connection to HTTPS sites offering TLS 1.3
Author: Andreas Metzler <ametzler@bebt.de>
Origin: https://lists.gnu.org/archive/html/lynx-dev/2018-12/msg00009.html

--- a/src/tidy_tls.c
+++ b/src/tidy_tls.c
@@ -462,13 +462,25 @@
 {
     int rc;
 
-    rc = (int) gnutls_record_recv(ssl->gnutls_state, buffer, (size_t) length);
+    do
+    {
+        rc = (int) gnutls_record_recv(ssl->gnutls_state, buffer, (size_t) length);
+    }
+    while ((rc == GNUTLS_E_AGAIN) || (rc == GNUTLS_E_INTERRUPTED));
 
     if (rc < 0 && gnutls_error_is_fatal(rc) == 0) {
 	if (rc == GNUTLS_E_REHANDSHAKE) {
 	    (void) gnutls_handshake(ssl->gnutls_state);
-	    gnutls_record_send(ssl->gnutls_state, ssl->sendbuffer, (size_t) ssl->bytes_sent);
-	    rc = (int) gnutls_record_recv(ssl->gnutls_state, buffer, (size_t) length);
+        do
+        {
+            rc = (int) gnutls_record_send(ssl->gnutls_state, ssl->sendbuffer, (size_t) ssl->bytes_sent);
+        }
+        while ((rc == GNUTLS_E_AGAIN) || (rc == GNUTLS_E_INTERRUPTED));
+        do
+        {
+	        rc = (int) gnutls_record_recv(ssl->gnutls_state, buffer, (size_t) length);
+        }
+        while ((rc == GNUTLS_E_AGAIN) || (rc == GNUTLS_E_INTERRUPTED));
 	}
     }
 
@@ -500,7 +512,11 @@
 {
     int rc;
 
-    rc = (int) gnutls_record_send(ssl->gnutls_state, buffer, (size_t) length);
+    do
+    {
+        rc = (int) gnutls_record_send(ssl->gnutls_state, buffer, (size_t) length);
+    }
+    while ((rc == GNUTLS_E_AGAIN) || (rc == GNUTLS_E_INTERRUPTED));
     ssl->last_error = rc;
 
     if (rc < 0) {