diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/chat-commands.c | 4 | ||||
-rw-r--r-- | src/core/network-openssl.c | 5 | ||||
-rw-r--r-- | src/irc/core/irc-servers.c | 18 | ||||
-rw-r--r-- | src/irc/core/sasl.c | 34 |
4 files changed, 44 insertions, 17 deletions
diff --git a/src/core/chat-commands.c b/src/core/chat-commands.c index 8e881679..7f000cf5 100644 --- a/src/core/chat-commands.c +++ b/src/core/chat-commands.c @@ -117,8 +117,8 @@ static SERVER_CONNECT_REC *get_server_connect(const char *data, int *plus_addr, if (g_hash_table_lookup(optlist, "!") != NULL) conn->no_autojoin_channels = TRUE; - if (g_hash_table_lookup(optlist, "noautosendcmd") != NULL) - conn->no_autosendcmd = TRUE; + if (g_hash_table_lookup(optlist, "noautosendcmd") != NULL) + conn->no_autosendcmd = TRUE; if (g_hash_table_lookup(optlist, "noproxy") != NULL) g_free_and_null(conn->proxy); diff --git a/src/core/network-openssl.c b/src/core/network-openssl.c index 465c4154..a18e6fc7 100644 --- a/src/core/network-openssl.c +++ b/src/core/network-openssl.c @@ -289,6 +289,7 @@ static GIOStatus irssi_ssl_read(GIOChannel *handle, gchar *buf, gsize len, gsize const char *errstr; gchar *errmsg; + ERR_clear_error(); ret1 = SSL_read(chan->ssl, buf, len); if(ret1 <= 0) { @@ -334,6 +335,7 @@ static GIOStatus irssi_ssl_write(GIOChannel *handle, const gchar *buf, gsize len const char *errstr; gchar *errmsg; + ERR_clear_error(); ret1 = SSL_write(chan->ssl, (const char *)buf, len); if(ret1 <= 0) { @@ -471,6 +473,7 @@ static GIOChannel *irssi_ssl_get_iochannel(GIOChannel *handle, int port, SERVER_ if(!(fd = g_io_channel_unix_get_fd(handle))) return NULL; + ERR_clear_error(); ctx = SSL_CTX_new(SSLv23_client_method()); if (ctx == NULL) { g_error("Could not allocate memory for SSL context"); @@ -489,6 +492,7 @@ static GIOChannel *irssi_ssl_get_iochannel(GIOChannel *handle, int port, SERVER_ scert = convert_home(mycert); if (mypkey && *mypkey) spkey = convert_home(mypkey); + ERR_clear_error(); if (! SSL_CTX_use_certificate_file(ctx, scert, SSL_FILETYPE_PEM)) g_warning("Loading of client certificate '%s' failed: %s", mycert, ERR_reason_error_string(ERR_get_error())); else if (! SSL_CTX_use_PrivateKey_file(ctx, spkey ? spkey : scert, SSL_FILETYPE_PEM)) @@ -581,6 +585,7 @@ int irssi_ssl_handshake(GIOChannel *handle) X509 *cert; const char *errstr; + ERR_clear_error(); ret = SSL_connect(chan->ssl); if (ret <= 0) { err = SSL_get_error(chan->ssl, ret); diff --git a/src/irc/core/irc-servers.c b/src/irc/core/irc-servers.c index 81f0c269..1df95f70 100644 --- a/src/irc/core/irc-servers.c +++ b/src/irc/core/irc-servers.c @@ -78,17 +78,23 @@ static int ischannel_func(SERVER_REC *server, const char *data) IRC_SERVER_REC *irc_server = (IRC_SERVER_REC *) server; char *chantypes, *statusmsg; + g_return_val_if_fail(data != NULL, FALSE); + + /* empty string is no channel */ + if (*data == '\0') + return FALSE; + chantypes = g_hash_table_lookup(irc_server->isupport, "chantypes"); if (chantypes == NULL) chantypes = "#&!+"; /* normal, local, secure, modeless */ - statusmsg = g_hash_table_lookup(irc_server->isupport, "statusmsg"); - if (statusmsg == NULL) - statusmsg = "@+"; - while (strchr(statusmsg, *data) != NULL) - data++; + statusmsg = g_hash_table_lookup(irc_server->isupport, "statusmsg"); + if (statusmsg != NULL) + data += strspn(data, statusmsg); - return strchr(chantypes, *data) != NULL; + /* strchr(3) considers the trailing NUL as part of the string, make sure + * we didn't advance too much. */ + return *data != '\0' && strchr(chantypes, *data) != NULL; } static char **split_line(const SERVER_REC *server, const char *line, diff --git a/src/irc/core/sasl.c b/src/irc/core/sasl.c index 8fba9ba2..b74b6a8c 100644 --- a/src/irc/core/sasl.c +++ b/src/irc/core/sasl.c @@ -34,7 +34,7 @@ static gboolean sasl_timeout(IRC_SERVER_REC *server) irc_send_cmd_now(server, "AUTHENTICATE *"); cap_finish_negotiation(server); - server->sasl_timeout = -1; + server->sasl_timeout = 0; signal_emit("server sasl failure", 2, server, "The authentication timed out"); @@ -64,9 +64,9 @@ static void sasl_fail(IRC_SERVER_REC *server, const char *data, const char *from char *params, *error; /* Stop any pending timeout, if any */ - if (server->sasl_timeout != -1) { + if (server->sasl_timeout != 0) { g_source_remove(server->sasl_timeout); - server->sasl_timeout = -1; + server->sasl_timeout = 0; } params = event_get_params(data, 2, NULL, &error); @@ -81,9 +81,9 @@ static void sasl_fail(IRC_SERVER_REC *server, const char *data, const char *from static void sasl_already(IRC_SERVER_REC *server, const char *data, const char *from) { - if (server->sasl_timeout != -1) { + if (server->sasl_timeout != 0) { g_source_remove(server->sasl_timeout); - server->sasl_timeout = -1; + server->sasl_timeout = 0; } signal_emit("server sasl success", 1, server); @@ -94,9 +94,9 @@ static void sasl_already(IRC_SERVER_REC *server, const char *data, const char *f static void sasl_success(IRC_SERVER_REC *server, const char *data, const char *from) { - if (server->sasl_timeout != -1) { + if (server->sasl_timeout != 0) { g_source_remove(server->sasl_timeout); - server->sasl_timeout = -1; + server->sasl_timeout = 0; } signal_emit("server sasl success", 1, server); @@ -114,9 +114,9 @@ static void sasl_step(IRC_SERVER_REC *server, const char *data, const char *from conn = server->connrec; /* Stop the timer */ - if (server->sasl_timeout != -1) { + if (server->sasl_timeout != 0) { g_source_remove(server->sasl_timeout); - server->sasl_timeout = -1; + server->sasl_timeout = 0; } switch (conn->sasl_mechanism) { @@ -153,6 +153,20 @@ static void sasl_step(IRC_SERVER_REC *server, const char *data, const char *from server->sasl_timeout = g_timeout_add(SASL_TIMEOUT, (GSourceFunc) sasl_timeout, server); } +static void sasl_disconnected(IRC_SERVER_REC *server) +{ + g_return_if_fail(server != NULL); + + if (!IS_IRC_SERVER(server)) { + return; + } + + if (server->sasl_timeout != 0) { + g_source_remove(server->sasl_timeout); + server->sasl_timeout = 0; + } +} + void sasl_init(void) { signal_add_first("server cap ack sasl", (SIGNAL_FUNC) sasl_start); @@ -163,6 +177,7 @@ void sasl_init(void) signal_add_first("event 905", (SIGNAL_FUNC) sasl_fail); signal_add_first("event 906", (SIGNAL_FUNC) sasl_fail); signal_add_first("event 907", (SIGNAL_FUNC) sasl_already); + signal_add_first("server disconnected", (SIGNAL_FUNC) sasl_disconnected); } void sasl_deinit(void) @@ -175,4 +190,5 @@ void sasl_deinit(void) signal_remove("event 905", (SIGNAL_FUNC) sasl_fail); signal_remove("event 906", (SIGNAL_FUNC) sasl_fail); signal_remove("event 907", (SIGNAL_FUNC) sasl_already); + signal_remove("server disconnected", (SIGNAL_FUNC) sasl_disconnected); } |