Skip to content
Permalink
Browse files Browse the repository at this point in the history
Fix null pointer dereference in echo-message
The bug was introduced while fixing #1705. If a client did not enable
echo-message, and doesn't have a network, it crashes.

Thanks to LunarBNC for reporting this
  • Loading branch information
DarthGandalf committed May 31, 2020
1 parent c16c343 commit 2390ad1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Client.cpp
Expand Up @@ -889,7 +889,7 @@ void CClient::EchoMessage(const CMessage& Message) {
CMessage EchoedMessage = Message;
for (CClient* pClient : GetClients()) {
if (pClient->HasEchoMessage() ||
(pClient != this && (m_pNetwork->IsChan(Message.GetParam(0)) ||
(pClient != this && ((m_pNetwork && m_pNetwork->IsChan(Message.GetParam(0))) ||
pClient->HasSelfMessage()))) {
EchoedMessage.SetNick(GetNickMask());
pClient->PutClient(EchoedMessage);
Expand Down
8 changes: 8 additions & 0 deletions test/integration/tests/core.cpp
Expand Up @@ -297,6 +297,14 @@ TEST_F(ZNCTest, StatusEchoMessage) {
client.Write("PRIVMSG *status :blah");
client.ReadUntil(":nick!user@irc.znc.in PRIVMSG *status :blah");
client.ReadUntil(":*status!znc@znc.in PRIVMSG nick :Unknown command");
client.Write("znc delnetwork test");
client.ReadUntil("Network deleted");
auto client2 = LoginClient();
client2.Write("PRIVMSG *status :blah2");
client2.ReadUntil(":*status!znc@znc.in PRIVMSG nick :Unknown command");
auto client3 = LoginClient();
client3.Write("PRIVMSG *status :blah3");
client3.ReadUntil(":*status!znc@znc.in PRIVMSG nick :Unknown command");
}

} // namespace
Expand Down

0 comments on commit 2390ad1

Please sign in to comment.