diff options
author | ailin-nemui <ailin-nemui@users.noreply.github.com> | 2016-03-20 22:06:41 +0100 |
---|---|---|
committer | ailin-nemui <ailin-nemui@users.noreply.github.com> | 2016-03-20 22:06:41 +0100 |
commit | 2ab26367139ebc6173cc117334e3f5d19ee0f071 (patch) | |
tree | 6ec77b4541fd6f6fe075ab412e3ffc3892aeca1d /src/irc | |
parent | c5e2f449847f8663d53bcd6dab64efa297a2ab70 (diff) | |
parent | f31d37a85271e0196aeefd409f0ab361ffd8c2ff (diff) | |
download | irssi-2ab26367139ebc6173cc117334e3f5d19ee0f071.zip |
Merge pull request #442 from LemonBoy/fix-435
Do not assume any default value for statusmsg.
Diffstat (limited to 'src/irc')
-rw-r--r-- | src/irc/core/irc-servers.c | 18 |
1 files changed, 12 insertions, 6 deletions
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, |