From 733e356cb77b0083ad06e54318d95303f8afaed8 Mon Sep 17 00:00:00 2001 From: Jafar Al-Gharaibeh Date: Sat, 6 Jan 2024 17:21:03 -0600 Subject: [PATCH] runtime: handle some SSL errors Signed-off-by: Jafar Al-Gharaibeh --- src/runtime/rposix.r | 8 ++++++-- src/runtime/rsys.r | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/runtime/rposix.r b/src/runtime/rposix.r index 129080dbf..f1ee14fc5 100644 --- a/src/runtime/rposix.r +++ b/src/runtime/rposix.r @@ -2425,7 +2425,7 @@ dptr u_read(dptr f, int n, int fstatus, dptr d) #if HAVE_LIBSSL if (fstatus & Fs_Encrypt) { tally = SSL_read(BlkD(*f,File)->fd.ssl, StrLoc(*d), n); - if (tally == 0) + if (tally <= 0) set_ssl_connection_errortext(BlkD(*f,File)->fd.ssl, tally); } else @@ -2482,8 +2482,12 @@ tryagain: #if HAVE_LIBSSL if (fstatus & Fs_Encrypt) { tally = SSL_read(BlkD(*f,File)->fd.ssl, StrLoc(*d) + i*bufsize, bufsize); - if (tally == 0) + if (tally <= 0) { set_ssl_connection_errortext(BlkD(*f,File)->fd.ssl, tally); + strtotal += bufsize; + strfree = StrLoc(*d); + return 0; + } } else { #endif /* LIBSSL */ diff --git a/src/runtime/rsys.r b/src/runtime/rsys.r index 0bc292860..47505f02e 100644 --- a/src/runtime/rsys.r +++ b/src/runtime/rsys.r @@ -23,7 +23,7 @@ dptr file; #if HAVE_LIBSSL if (BlkD(*file, File)->status & Fs_Encrypt) { r = SSL_peek(BlkD(*file, File)->fd.ssl, buf, maxi); - if (r == 0) { + if (r <= 0) { if (set_ssl_connection_errortext(BlkD(*file, File)->fd.ssl, r) == SSL_ERROR_ZERO_RETURN) return -1; else @@ -66,7 +66,7 @@ dptr file; #if HAVE_LIBSSL if (BlkD(*file, File)->status & Fs_Encrypt) { r = SSL_read(BlkD(*file,File)->fd.ssl, buf, i); - if (r == 0) { + if (r <= 0) { if (set_ssl_connection_errortext(BlkD(*file,File)->fd.ssl, r) == SSL_ERROR_ZERO_RETURN) return -1; else