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:
parent
daf6adc0b0
commit
ec83dd762a
@ -247,6 +247,7 @@ static GIOStatus irssi_ssl_read(GIOChannel *handle, gchar *buf, gsize len, gsize
|
|||||||
GIOSSLChannel *chan = (GIOSSLChannel *)handle;
|
GIOSSLChannel *chan = (GIOSSLChannel *)handle;
|
||||||
gint ret1, err;
|
gint ret1, err;
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
|
gchar *errmsg;
|
||||||
|
|
||||||
ret1 = SSL_read(chan->ssl, buf, len);
|
ret1 = SSL_read(chan->ssl, buf, len);
|
||||||
if(ret1 <= 0)
|
if(ret1 <= 0)
|
||||||
@ -271,9 +272,10 @@ static GIOStatus irssi_ssl_read(GIOChannel *handle, gchar *buf, gsize len, gsize
|
|||||||
if (errstr == NULL)
|
if (errstr == NULL)
|
||||||
errstr = "unknown SSL error";
|
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,
|
*gerr = g_error_new_literal(G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_FAILED,
|
||||||
errstr);
|
errmsg);
|
||||||
|
g_free(errmsg);
|
||||||
return G_IO_STATUS_ERROR;
|
return G_IO_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -290,6 +292,7 @@ static GIOStatus irssi_ssl_write(GIOChannel *handle, const gchar *buf, gsize len
|
|||||||
GIOSSLChannel *chan = (GIOSSLChannel *)handle;
|
GIOSSLChannel *chan = (GIOSSLChannel *)handle;
|
||||||
gint ret1, err;
|
gint ret1, err;
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
|
gchar *errmsg;
|
||||||
|
|
||||||
ret1 = SSL_write(chan->ssl, (const char *)buf, len);
|
ret1 = SSL_write(chan->ssl, (const char *)buf, len);
|
||||||
if(ret1 <= 0)
|
if(ret1 <= 0)
|
||||||
@ -314,9 +317,10 @@ static GIOStatus irssi_ssl_write(GIOChannel *handle, const gchar *buf, gsize len
|
|||||||
if (errstr == NULL)
|
if (errstr == NULL)
|
||||||
errstr = "unknown SSL error";
|
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,
|
*gerr = g_error_new_literal(G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_FAILED,
|
||||||
errstr);
|
errmsg);
|
||||||
|
g_free(errmsg);
|
||||||
return G_IO_STATUS_ERROR;
|
return G_IO_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -349,11 +349,16 @@ int net_receive(GIOChannel *handle, char *buf, int len)
|
|||||||
{
|
{
|
||||||
gsize ret;
|
gsize ret;
|
||||||
GIOStatus status;
|
GIOStatus status;
|
||||||
|
GError *err = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail(handle != NULL, -1);
|
g_return_val_if_fail(handle != NULL, -1);
|
||||||
g_return_val_if_fail(buf != 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)
|
if (status == G_IO_STATUS_ERROR || status == G_IO_STATUS_EOF)
|
||||||
return -1; /* disconnected */
|
return -1; /* disconnected */
|
||||||
|
|
||||||
@ -365,11 +370,16 @@ int net_transmit(GIOChannel *handle, const char *data, int len)
|
|||||||
{
|
{
|
||||||
gsize ret;
|
gsize ret;
|
||||||
GIOStatus status;
|
GIOStatus status;
|
||||||
|
GError *err = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail(handle != NULL, -1);
|
g_return_val_if_fail(handle != NULL, -1);
|
||||||
g_return_val_if_fail(data != 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)
|
if (status == G_IO_STATUS_ERROR)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user