summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJase Thew <bazerka@irssi.org>2010-05-16 17:50:31 +0000
committerbazerka <bazerka@dbcabf3a-b0e7-0310-adc4-f8d773084564>2010-05-16 17:50:31 +0000
commitec83dd762ada05170a9c80c6582c4754c66f9f0d (patch)
treef1b92a1be4cad59802444d7108b85bab89ba5ba9
parentdaf6adc0b098fdae473e8276cab88ebec6a3ae09 (diff)
downloadirssi-ec83dd762ada05170a9c80c6582c4754c66f9f0d.zip
Fix segfault generated by SSL disconnections. (Bug #752)
git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@5170 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r--src/core/network-openssl.c12
-rw-r--r--src/core/network.c14
2 files changed, 20 insertions, 6 deletions
diff --git a/src/core/network-openssl.c b/src/core/network-openssl.c
index 2c711c78..3191a1bd 100644
--- a/src/core/network-openssl.c
+++ b/src/core/network-openssl.c
@@ -247,6 +247,7 @@ static GIOStatus irssi_ssl_read(GIOChannel *handle, gchar *buf, gsize len, gsize
GIOSSLChannel *chan = (GIOSSLChannel *)handle;
gint ret1, err;
const char *errstr;
+ gchar *errmsg;
ret1 = SSL_read(chan->ssl, buf, len);
if(ret1 <= 0)
@@ -271,9 +272,10 @@ static GIOStatus irssi_ssl_read(GIOChannel *handle, gchar *buf, gsize len, gsize
if (errstr == NULL)
errstr = "unknown SSL error";
}
- g_warning("SSL read error: %s", errstr);
+ errmsg = g_strdup_printf("SSL read error: %s", errstr);
*gerr = g_error_new_literal(G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_FAILED,
- errstr);
+ errmsg);
+ g_free(errmsg);
return G_IO_STATUS_ERROR;
}
else
@@ -290,6 +292,7 @@ static GIOStatus irssi_ssl_write(GIOChannel *handle, const gchar *buf, gsize len
GIOSSLChannel *chan = (GIOSSLChannel *)handle;
gint ret1, err;
const char *errstr;
+ gchar *errmsg;
ret1 = SSL_write(chan->ssl, (const char *)buf, len);
if(ret1 <= 0)
@@ -314,9 +317,10 @@ static GIOStatus irssi_ssl_write(GIOChannel *handle, const gchar *buf, gsize len
if (errstr == NULL)
errstr = "unknown SSL error";
}
- g_warning("SSL write error: %s", errstr);
+ errmsg = g_strdup_printf("SSL write error: %s", errstr);
*gerr = g_error_new_literal(G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_FAILED,
- errstr);
+ errmsg);
+ g_free(errmsg);
return G_IO_STATUS_ERROR;
}
else
diff --git a/src/core/network.c b/src/core/network.c
index 8f5d3e8d..d7c1017c 100644
--- a/src/core/network.c
+++ b/src/core/network.c
@@ -349,11 +349,16 @@ int net_receive(GIOChannel *handle, char *buf, int len)
{
gsize ret;
GIOStatus status;
+ GError *err = NULL;
g_return_val_if_fail(handle != NULL, -1);
g_return_val_if_fail(buf != NULL, -1);
- status = g_io_channel_read_chars(handle, buf, len, &ret, NULL);
+ status = g_io_channel_read_chars(handle, buf, len, &ret, &err);
+ if (err != NULL) {
+ g_warning(err->message);
+ g_error_free(err);
+ }
if (status == G_IO_STATUS_ERROR || status == G_IO_STATUS_EOF)
return -1; /* disconnected */
@@ -365,11 +370,16 @@ int net_transmit(GIOChannel *handle, const char *data, int len)
{
gsize ret;
GIOStatus status;
+ GError *err = NULL;
g_return_val_if_fail(handle != NULL, -1);
g_return_val_if_fail(data != NULL, -1);
- status = g_io_channel_write_chars(handle, (char *) data, len, &ret, NULL);
+ status = g_io_channel_write_chars(handle, (char *) data, len, &ret, &err);
+ if (err != NULL) {
+ g_warning(err->message);
+ g_error_free(err);
+ }
if (status == G_IO_STATUS_ERROR)
return -1;