summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNei <ailin.nemui@gmail.com>2018-02-06 06:46:11 +0000
committerNei <ailin.nemui@gmail.com>2018-02-06 06:46:11 +0000
commit12483c688ae231ce5367d080720c22253855a5ce (patch)
tree2ba065c56dd1a37db0b7ecc33dc84f9dfb1380b5
parenta73659e0ea5d50c4da7a4da805cda13068098646 (diff)
parent84f03e01467b90a4251987b32b2813ee976b357c (diff)
downloadirssi-12483c688ae231ce5367d080720c22253855a5ce.zip
Merge branch 'sasl-timeout' into 'security'
Fix Sasl timeout error See merge request irssi/irssi!33
-rw-r--r--src/irc/core/sasl.c39
1 files changed, 16 insertions, 23 deletions
diff --git a/src/irc/core/sasl.c b/src/irc/core/sasl.c
index 2b589579..c5aa2caa 100644
--- a/src/irc/core/sasl.c
+++ b/src/irc/core/sasl.c
@@ -55,10 +55,21 @@ static gboolean sasl_timeout(IRC_SERVER_REC *server)
return FALSE;
}
+static void sasl_timeout_stop(IRC_SERVER_REC *server)
+{
+ /* Stop any pending timeout, if any */
+ if (server->sasl_timeout != 0) {
+ g_source_remove(server->sasl_timeout);
+ server->sasl_timeout = 0;
+ }
+}
+
static void sasl_start(IRC_SERVER_REC *server, const char *data, const char *from)
{
IRC_SERVER_CONNECT_REC *conn;
+ sasl_timeout_stop(server);
+
conn = server->connrec;
switch (conn->sasl_mechanism) {
@@ -77,11 +88,6 @@ 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 != 0) {
- g_source_remove(server->sasl_timeout);
- server->sasl_timeout = 0;
- }
params = event_get_params(data, 2, NULL, &error);
@@ -97,10 +103,7 @@ 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 != 0) {
- g_source_remove(server->sasl_timeout);
- server->sasl_timeout = 0;
- }
+ sasl_timeout_stop(server);
server->sasl_success = TRUE;
@@ -112,10 +115,7 @@ 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 != 0) {
- g_source_remove(server->sasl_timeout);
- server->sasl_timeout = 0;
- }
+ sasl_timeout_stop(server);
server->sasl_success = TRUE;
@@ -265,7 +265,7 @@ static void sasl_step_fail(IRC_SERVER_REC *server)
irc_send_cmd_now(server, "AUTHENTICATE *");
cap_finish_negotiation(server);
- server->sasl_timeout = 0;
+ sasl_timeout_stop(server);
signal_emit("server sasl failure", 2, server, "The server sent an invalid payload");
}
@@ -274,11 +274,7 @@ static void sasl_step(IRC_SERVER_REC *server, const char *data, const char *from
{
GString *req = NULL;
- /* Stop the timer */
- if (server->sasl_timeout != 0) {
- g_source_remove(server->sasl_timeout);
- server->sasl_timeout = 0;
- }
+ sasl_timeout_stop(server);
if (!sasl_reassemble_incoming(server, data, &req)) {
sasl_step_fail(server);
@@ -302,10 +298,7 @@ static void sasl_disconnected(IRC_SERVER_REC *server)
return;
}
- if (server->sasl_timeout != 0) {
- g_source_remove(server->sasl_timeout);
- server->sasl_timeout = 0;
- }
+ sasl_timeout_stop(server);
}
void sasl_init(void)