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

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
This commit is contained in:
Jase Thew 2010-05-16 17:50:31 +00:00 committed by bazerka
parent daf6adc0b0
commit ec83dd762a
2 changed files with 20 additions and 6 deletions

View File

@ -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

View File

@ -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;