Skip to content

Commit

Permalink
mod_discord: Fix NULL dereference.
Browse files Browse the repository at this point in the history
It seems that echochan can be NULL
even when echoguildid is set, so
add a NULL check before doing string
comparison.

Also remove unnecessary module self-ref/unref
from net_irc.
  • Loading branch information
InterLinked1 committed Jan 3, 2024
1 parent b24f137 commit 47f8302
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 3 additions & 1 deletion modules/mod_discord.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,9 @@ static void fetch_channels(struct discord *client, u64snowflake guild_id, u64sno

#ifdef RELAY_RCV_EVENTUALLY_FAILS
if (echoguildid && echoguildid == guild_id) {
if (!strcmp(echochan, channel->name)) {
if (strlen_zero(echochan)) {
bbs_warning("Echo guild ID is %lu but no echo channel parsed?\n", echoguildid);
} else if (!strcmp(echochan, channel->name)) {
echochanid = channel->id;
bbs_debug(1, "Channel %lu/%lu configured as echo channel\n", echoguildid, echochanid);
}
Expand Down
2 changes: 0 additions & 2 deletions nets/net_irc.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ int irc_chanserv_register(void (*privmsg)(const char *username, char *msg), void
return -1;
}
/* This is the right order for these operations. Use reverse order for unregister. */
bbs_module_ref(BBS_MODULE_SELF, 2); /* Bump our module ref count */
chanserv_mod = mod;
chanserv_privmsg = privmsg;
chanserv_eventcb = eventcb;
Expand All @@ -401,7 +400,6 @@ int irc_chanserv_unregister(void (*privmsg)(const char *username, char *msg))
chanserv_privmsg = NULL;
chanserv_eventcb = NULL;
chanserv_mod = NULL;
bbs_module_unref(BBS_MODULE_SELF, 2);
return 0;
}

Expand Down

0 comments on commit 47f8302

Please sign in to comment.