/pidgin/main: 7d0fb0c6d8d4: Add back some checks for gc!=NULL.

Mark Doliner mark at kingant.net
Tue Jan 28 10:38:13 EST 2014


Changeset: 7d0fb0c6d8d445dfd677b488c980ba384a57a093
Author:	 Mark Doliner <mark at kingant.net>
Date:	 2014-01-18 10:22 -0800
Branch:	 release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/7d0fb0c6d8d4

Description:

Add back some checks for gc!=NULL.

We should try to centralize this check in main because I think there might
not be a time when we're parsing incoming data and gc is null.

diffstat:

 libpurple/protocols/irc/msgs.c |  26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diffs (106 lines):

diff --git a/libpurple/protocols/irc/msgs.c b/libpurple/protocols/irc/msgs.c
--- a/libpurple/protocols/irc/msgs.c
+++ b/libpurple/protocols/irc/msgs.c
@@ -20,6 +20,12 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
  */
 
+/*
+ * Note: If you change any of these functions to use additional args you
+ * MUST ensure the arg count is correct in parse.c. Otherwise it may be
+ * possible for a malicious server or man-in-the-middle to trigger a crash.
+ */
+
 #include "internal.h"
 
 #include "conversation.h"
@@ -250,6 +256,8 @@ void irc_msg_badmode(struct irc_conn *ir
 {
 	PurpleConnection *gc = purple_account_get_connection(irc->account);
 
+	g_return_if_fail(gc);
+
 	purple_notify_error(gc, NULL, _("Bad mode"), args[1]);
 }
 
@@ -299,6 +307,8 @@ void irc_msg_banned(struct irc_conn *irc
 	PurpleConnection *gc = purple_account_get_connection(irc->account);
 	char *buf;
 
+	g_return_if_fail(gc);
+
 	buf = g_strdup_printf(_("You are banned from %s."), args[1]);
 	purple_notify_error(gc, _("Banned"), _("Banned"), buf);
 	g_free(buf);
@@ -645,6 +655,8 @@ void irc_msg_unknown(struct irc_conn *ir
 	PurpleConnection *gc = purple_account_get_connection(irc->account);
 	char *buf;
 
+	g_return_if_fail(gc);
+
 	buf = g_strdup_printf(_("Unknown message '%s'"), args[1]);
 	purple_notify_error(gc, _("Unknown message"), buf, _("The IRC server received a message it did not understand."));
 	g_free(buf);
@@ -773,6 +785,8 @@ void irc_msg_time(struct irc_conn *irc, 
 {
 	PurpleConnection *gc = purple_account_get_connection(irc->account);
 
+	g_return_if_fail(gc);
+
 	purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO, _("Time Response"),
 			    _("The IRC server's local time is:"),
 			    args[2], NULL, NULL);
@@ -782,6 +796,8 @@ void irc_msg_nochan(struct irc_conn *irc
 {
 	PurpleConnection *gc = purple_account_get_connection(irc->account);
 
+	g_return_if_fail(gc);
+
 	purple_notify_error(gc, NULL, _("No such channel"), args[1]);
 }
 
@@ -870,6 +886,8 @@ void irc_msg_inviteonly(struct irc_conn 
 	PurpleConnection *gc = purple_account_get_connection(irc->account);
 	char *buf;
 
+	g_return_if_fail(gc);
+
 	buf = g_strdup_printf(_("Joining %s requires an invitation."), args[1]);
 	purple_notify_error(gc, _("Invitation only"), _("Invitation only"), buf);
 	g_free(buf);
@@ -1179,6 +1197,8 @@ void irc_msg_nochangenick(struct irc_con
 {
 	PurpleConnection *gc = purple_account_get_connection(irc->account);
 
+	g_return_if_fail(gc);
+
 	purple_notify_error(gc, _("Cannot change nick"), _("Could not change nick"), args[2]);
 }
 
@@ -1320,6 +1340,8 @@ void irc_msg_regonly(struct irc_conn *ir
 	PurpleConversation *convo;
 	char *msg;
 
+	g_return_if_fail(gc);
+
 	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account);
 	if (convo) {
 		/* This is a channel we're already in; for some reason,
@@ -1340,6 +1362,8 @@ void irc_msg_quit(struct irc_conn *irc, 
 	struct irc_buddy *ib;
 	char *data[2];
 
+	g_return_if_fail(gc);
+
 	data[0] = irc_mask_nick(from);
 	data[1] = args[0];
 	/* XXX this should have an API, I shouldn't grab this directly */
@@ -1366,6 +1390,8 @@ void irc_msg_wallops(struct irc_conn *ir
 	PurpleConnection *gc = purple_account_get_connection(irc->account);
 	char *nick, *msg;
 
+	g_return_if_fail(gc);
+
 	nick = irc_mask_nick(from);
 	msg = g_strdup_printf (_("Wallops from %s"), nick);
 	g_free(nick);



More information about the Commits mailing list