summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2025-01-08 19:17:42 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2025-01-08 19:22:36 +0100
commit20c9b6894790ef5f9b763e429dbd8f51c2e091e2 (patch)
tree723d38897811816952ee3329fa68ba7a416b622e /methods
parenta8be42ef4de786b4dacdc175419df92ab0193ed9 (diff)
ssl: Explictly return -1 (error) or 0 (server closed connection)
SSL_read() and SSL_write may return 0 for errors, whereas our callers only expect -1 for errors and 0 for closed connections, so map this accordingly.
Diffstat (limited to 'methods')
-rw-r--r--methods/connect.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/methods/connect.cc b/methods/connect.cc
index c685ac031..eeee7c509 100644
--- a/methods/connect.cc
+++ b/methods/connect.cc
@@ -842,22 +842,26 @@ struct TlsFd final : public MethodFd
case SSL_ERROR_WANT_READ:
case SSL_ERROR_WANT_WRITE:
errno = EAGAIN;
- break;
+ return -1;
case SSL_ERROR_ZERO_RETURN:
// Remote host has closed connection
errno = 0;
- break;
+ return 0;
case SSL_ERROR_SYSCALL:
broken = true;
_error->Errno("openssl", "OpenSSL system call error: %s\n", ssl_strerr());
- break;
+ return -1;
case SSL_ERROR_SSL:
broken = true;
errno = EIO;
_error->Error("OpenSSL error: %s\n", ssl_strerr());
- break;
+ return -1;
+ default:
+ broken = true;
+ errno = EIO;
+ _error->Error("Unexpected OpenSSL error: %s\n", ssl_strerr());
+ return -1;
}
- return r;
}
int Close() override