Skip to content

Commit

Permalink
Merge pull request #355 from Jafaral/fix-ssl-ready
Browse files Browse the repository at this point in the history
runtime: handle some SSL errors
  • Loading branch information
Don-Ward authored Jan 8, 2024
2 parents 35e04e4 + 733e356 commit 5640082
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/runtime/rposix.r
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/rsys.r
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5640082

Please sign in to comment.