1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Fix crash when SSL-connecting to something which closes

the connection immediately. Also clarify the error message
when the SSL handshake fails.
This bug was introduced after 0.8.11.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4576 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Jilles Tjoelker 2007-07-08 18:39:32 +00:00 committed by jilles
parent 3b72b51257
commit 55c2d17c2b

View File

@ -323,12 +323,14 @@ int irssi_ssl_handshake(GIOChannel *handle)
GIOSSLChannel *chan = (GIOSSLChannel *)handle; GIOSSLChannel *chan = (GIOSSLChannel *)handle;
int ret, err; int ret, err;
X509 *cert; X509 *cert;
const char *errstr;
ret = SSL_connect(chan->ssl); ret = SSL_connect(chan->ssl);
if (ret <= 0) { if (ret <= 0) {
err = SSL_get_error(chan->ssl, ret); err = SSL_get_error(chan->ssl, ret);
if (err != SSL_ERROR_WANT_READ && err != SSL_ERROR_WANT_WRITE) { if (err != SSL_ERROR_WANT_READ && err != SSL_ERROR_WANT_WRITE) {
g_warning(ERR_reason_error_string(ERR_get_error())); errstr = ERR_reason_error_string(ERR_get_error());
g_warning("SSL handshake failed: %s", errstr != NULL ? errstr : "server closed connection");
return -1; return -1;
} }
return err == SSL_ERROR_WANT_READ ? 1 : 3; return err == SSL_ERROR_WANT_READ ? 1 : 3;