From 133b0f7d9425219c291f58f12421ff1f2dbdfcbb Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 24 May 2013 20:29:15 +0100 Subject: Fixed null pointer deref when we try to autojoin a channel of a network not in the network list. --- src/common/inbound.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/common/inbound.c b/src/common/inbound.c index da2cb34c..d0424296 100644 --- a/src/common/inbound.c +++ b/src/common/inbound.c @@ -1093,7 +1093,8 @@ check_autojoin_channels (server *serv) strcpy (sess->waitchannel, sess->willjoinchannel); sess->willjoinchannel[0] = 0; - fav = servlist_favchan_find (serv->network, sess->waitchannel, NULL); /* Is this channel in our favorites? */ + /* Is this channel in our favorites? */ + fav = serv->network == NULL ? NULL : servlist_favchan_find (serv->network, sess->waitchannel, NULL); /* session->channelkey is initially unset for channels joined from the favorites. You have to fill them up manually from favorites settings. */ if (fav) -- cgit 1.4.1 From 7353bf269817ead3c473c47b60f5b6b66900de73 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 24 May 2013 21:49:46 +0100 Subject: Followed richtroye suggestion and implemented the net == NULL guard in servlist_favchan_find(). --- src/common/inbound.c | 2 +- src/common/servlist.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/common/inbound.c b/src/common/inbound.c index d0424296..bbdd89c6 100644 --- a/src/common/inbound.c +++ b/src/common/inbound.c @@ -1094,7 +1094,7 @@ check_autojoin_channels (server *serv) sess->willjoinchannel[0] = 0; /* Is this channel in our favorites? */ - fav = serv->network == NULL ? NULL : servlist_favchan_find (serv->network, sess->waitchannel, NULL); + fav = servlist_favchan_find (serv->network, sess->waitchannel, NULL); /* session->channelkey is initially unset for channels joined from the favorites. You have to fill them up manually from favorites settings. */ if (fav) diff --git a/src/common/servlist.c b/src/common/servlist.c index d121dd47..a0a85695 100644 --- a/src/common/servlist.c +++ b/src/common/servlist.c @@ -877,10 +877,15 @@ servlist_server_find (ircnet *net, char *name, int *pos) favchannel * servlist_favchan_find (ircnet *net, char *channel, int *pos) { - GSList *list = net->favchanlist; + GSList *list; favchannel *favchan; int i = 0; + if (net == NULL) + return NULL; + + list = net->favchanlist; + while (list) { favchan = list->data; -- cgit 1.4.1 From fffe9f4bd9dea9f61f19eeee08dea0c4dd072244 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 24 May 2013 22:04:34 +0100 Subject: Restored inbound.c to make the pull request cleaner. --- src/common/inbound.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/common/inbound.c b/src/common/inbound.c index bbdd89c6..da2cb34c 100644 --- a/src/common/inbound.c +++ b/src/common/inbound.c @@ -1093,8 +1093,7 @@ check_autojoin_channels (server *serv) strcpy (sess->waitchannel, sess->willjoinchannel); sess->willjoinchannel[0] = 0; - /* Is this channel in our favorites? */ - fav = servlist_favchan_find (serv->network, sess->waitchannel, NULL); + fav = servlist_favchan_find (serv->network, sess->waitchannel, NULL); /* Is this channel in our favorites? */ /* session->channelkey is initially unset for channels joined from the favorites. You have to fill them up manually from favorites settings. */ if (fav) -- cgit 1.4.1