Blame SOURCES/Net-SSLeay-1.85-Move-SSL_ERROR_WANT_READ-SSL_ERROR_WANT_WRITE-retry-from_write_partial.patch

20bab0
From 122c80853a9bd66f21699fc79a689b3028d00d3b Mon Sep 17 00:00:00 2001
20bab0
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
20bab0
Date: Fri, 17 Aug 2018 13:08:44 +0200
20bab0
Subject: [PATCH] Move SSL_ERROR_WANT_READ/SSL_ERROR_WANT_WRITE retry from
20bab0
 write_partial()
20bab0
MIME-Version: 1.0
20bab0
Content-Type: text/plain; charset=UTF-8
20bab0
Content-Transfer-Encoding: 8bit
20bab0
20bab0
Original OpenSSL 1.1.1 fix broke IO-Socket-SSL-2.058's t/nonblock.t test
20bab0
because it tests non-blocking socket operations and expects to see
20bab0
SSL_ERROR_WANT_WRITE errors and to handle them byt itself.
20bab0
20bab0
This patch purifies Net::SSLeay::write_partial() to behave exactly as
20bab0
underlying OpenSSL SSL_write() function. The retry is already
20bab0
presented in Net::SSLeay::ssl_write_all().
20bab0
20bab0
All applications should implement the retry themsleves or use
20bab0
ssl_*_all() instead.
20bab0
20bab0
Signed-off-by: Petr Písař <ppisar@redhat.com>
20bab0
---
20bab0
 SSLeay.xs          | 16 ++--------------
20bab0
 lib/Net/SSLeay.pod |  3 ++-
20bab0
 2 files changed, 4 insertions(+), 15 deletions(-)
20bab0
20bab0
diff --git a/SSLeay.xs b/SSLeay.xs
20bab0
index 7cb6eab..fc7677f 100644
20bab0
--- a/SSLeay.xs
20bab0
+++ b/SSLeay.xs
20bab0
@@ -2089,20 +2089,8 @@ SSL_write_partial(s,from,count,buf)
20bab0
      if (len < 0) {
20bab0
        croak("from beyound end of buffer");
20bab0
        RETVAL = -1;
20bab0
-     } else {
20bab0
-	     int ret;
20bab0
-	     int err;
20bab0
-
20bab0
-	     do {
20bab0
-		     ret = SSL_write (s, &(buf[from]), (count<=len)?count:len);
20bab0
-		     if (ret > 0)
20bab0
-			     break;
20bab0
-		     err = SSL_get_error(s, ret);
20bab0
-		     if (err != SSL_ERROR_WANT_READ && err != SSL_ERROR_WANT_WRITE)
20bab0
-			     break;
20bab0
-	     } while (1);
20bab0
-	     RETVAL = ret;
20bab0
-     }
20bab0
+     } else
20bab0
+       RETVAL = SSL_write (s, &(buf[from]), (count<=len)?count:len);
20bab0
      OUTPUT:
20bab0
      RETVAL
20bab0
 
20bab0
diff --git a/lib/Net/SSLeay.pod b/lib/Net/SSLeay.pod
20bab0
index bca7be4..8b5f738 100644
20bab0
--- a/lib/Net/SSLeay.pod
20bab0
+++ b/lib/Net/SSLeay.pod
20bab0
@@ -4819,7 +4819,8 @@ Check openssl doc L
20bab0
 
20bab0
 B<NOTE:> Does not exactly correspond to any low level API function
20bab0
 
20bab0
-Writes a fragment of data in $data from the buffer $data into the specified $ssl connection.
20bab0
+Writes a fragment of data in $data from the buffer $data into the specified
20bab0
+$ssl connection. This is a non-blocking function like L<Net::SSLeay::write()>.
20bab0
 
20bab0
  my $rv = Net::SSLeay::write_partial($ssl, $from, $count, $data);
20bab0
  # $ssl - value corresponding to openssl's SSL structure
20bab0
-- 
20bab0
2.14.4
20bab0