diff options
author | Patrick Griffis <tingping@tingping.se> | 2019-11-24 13:01:48 -0800 |
---|---|---|
committer | Patrick Griffis <tingping@tingping.se> | 2019-11-24 13:01:48 -0800 |
commit | 7d9f3acfc905ca5d0c9747699eb21d2d95fbf821 (patch) | |
tree | 448c43e0eaca1252cc9cf15a0a7c667d4ca1d9fd /src/common/inbound.c | |
parent | ad5be08a0703659e1b90ec4a5c6ff58a42660bae (diff) |
Fix capability negotiation ending before sasl finishes with multi-line cap
Closes #2398
Diffstat (limited to 'src/common/inbound.c')
-rw-r--r-- | src/common/inbound.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/common/inbound.c b/src/common/inbound.c index 9c77b231..eb7054f2 100644 --- a/src/common/inbound.c +++ b/src/common/inbound.c @@ -1768,7 +1768,6 @@ inbound_cap_ls (server *serv, char *nick, char *extensions_str, { char buffer[500]; /* buffer for requesting capabilities and emitting the signal */ gboolean want_cap = FALSE; /* format the CAP REQ string based on previous capabilities being requested or not */ - gboolean want_sasl = FALSE; /* CAP END shouldn't be sent when SASL is requested, it needs further responses */ char **extensions; int i; @@ -1816,7 +1815,7 @@ inbound_cap_ls (server *serv, char *nick, char *extensions_str, serv->sasl_mech = sasl_mech; } want_cap = TRUE; - want_sasl = TRUE; + serv->waiting_on_sasl = TRUE; g_strlcat (buffer, "sasl ", sizeof(buffer)); continue; } @@ -1842,7 +1841,7 @@ inbound_cap_ls (server *serv, char *nick, char *extensions_str, tags_data->timestamp); tcp_sendf (serv, "%s\r\n", g_strchomp (buffer)); } - if (!want_sasl && !serv->waiting_on_cap) + if (!serv->waiting_on_sasl && !serv->waiting_on_cap) { /* if we use SASL, CAP END is dealt via raw numerics */ serv->sent_capend = TRUE; @@ -1851,13 +1850,25 @@ inbound_cap_ls (server *serv, char *nick, char *extensions_str, } void -inbound_cap_nak (server *serv, const message_tags_data *tags_data) +inbound_cap_nak (server *serv, char *extensions_str, const message_tags_data *tags_data) { - if (!serv->waiting_on_cap && !serv->sent_capend) + char **extensions; + int i; + + extensions = g_strsplit (extensions_str, " ", 0); + for (i=0; extensions[i]; i++) + { + if (!g_strcmp0 (extensions[i], "sasl")) + serv->waiting_on_sasl = FALSE; + } + + if (!serv->waiting_on_cap && !serv->waiting_on_sasl && !serv->sent_capend) { serv->sent_capend = TRUE; tcp_send_len (serv, "CAP END\r\n", 9); } + + g_strfreev (extensions); } void |