Add back some checks for gc!=NULL. release-2.x.y
authorMark Doliner <mark@kingant.net>
Sat, 18 Jan 2014 10:22:41 -0800
branchrelease-2.x.y
changeset7d0fb0c6d8d4 pushlog
parent 4d9be297d399
child 635339ce6bf7
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.
libpurple/protocols/irc/msgs.c
     1.1 --- a/libpurple/protocols/irc/msgs.c
     1.2 +++ b/libpurple/protocols/irc/msgs.c
     1.3 @@ -20,6 +20,12 @@
     1.4   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
     1.5   */
     1.6  
     1.7 +/*
     1.8 + * Note: If you change any of these functions to use additional args you
     1.9 + * MUST ensure the arg count is correct in parse.c. Otherwise it may be
    1.10 + * possible for a malicious server or man-in-the-middle to trigger a crash.
    1.11 + */
    1.12 +
    1.13  #include "internal.h"
    1.14  
    1.15  #include "conversation.h"
    1.16 @@ -250,6 +256,8 @@
    1.17  {
    1.18  	PurpleConnection *gc = purple_account_get_connection(irc->account);
    1.19  
    1.20 +	g_return_if_fail(gc);
    1.21 +
    1.22  	purple_notify_error(gc, NULL, _("Bad mode"), args[1]);
    1.23  }
    1.24  
    1.25 @@ -299,6 +307,8 @@
    1.26  	PurpleConnection *gc = purple_account_get_connection(irc->account);
    1.27  	char *buf;
    1.28  
    1.29 +	g_return_if_fail(gc);
    1.30 +
    1.31  	buf = g_strdup_printf(_("You are banned from %s."), args[1]);
    1.32  	purple_notify_error(gc, _("Banned"), _("Banned"), buf);
    1.33  	g_free(buf);
    1.34 @@ -645,6 +655,8 @@
    1.35  	PurpleConnection *gc = purple_account_get_connection(irc->account);
    1.36  	char *buf;
    1.37  
    1.38 +	g_return_if_fail(gc);
    1.39 +
    1.40  	buf = g_strdup_printf(_("Unknown message '%s'"), args[1]);
    1.41  	purple_notify_error(gc, _("Unknown message"), buf, _("The IRC server received a message it did not understand."));
    1.42  	g_free(buf);
    1.43 @@ -773,6 +785,8 @@
    1.44  {
    1.45  	PurpleConnection *gc = purple_account_get_connection(irc->account);
    1.46  
    1.47 +	g_return_if_fail(gc);
    1.48 +
    1.49  	purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO, _("Time Response"),
    1.50  			    _("The IRC server's local time is:"),
    1.51  			    args[2], NULL, NULL);
    1.52 @@ -782,6 +796,8 @@
    1.53  {
    1.54  	PurpleConnection *gc = purple_account_get_connection(irc->account);
    1.55  
    1.56 +	g_return_if_fail(gc);
    1.57 +
    1.58  	purple_notify_error(gc, NULL, _("No such channel"), args[1]);
    1.59  }
    1.60  
    1.61 @@ -870,6 +886,8 @@
    1.62  	PurpleConnection *gc = purple_account_get_connection(irc->account);
    1.63  	char *buf;
    1.64  
    1.65 +	g_return_if_fail(gc);
    1.66 +
    1.67  	buf = g_strdup_printf(_("Joining %s requires an invitation."), args[1]);
    1.68  	purple_notify_error(gc, _("Invitation only"), _("Invitation only"), buf);
    1.69  	g_free(buf);
    1.70 @@ -1179,6 +1197,8 @@
    1.71  {
    1.72  	PurpleConnection *gc = purple_account_get_connection(irc->account);
    1.73  
    1.74 +	g_return_if_fail(gc);
    1.75 +
    1.76  	purple_notify_error(gc, _("Cannot change nick"), _("Could not change nick"), args[2]);
    1.77  }
    1.78  
    1.79 @@ -1320,6 +1340,8 @@
    1.80  	PurpleConversation *convo;
    1.81  	char *msg;
    1.82  
    1.83 +	g_return_if_fail(gc);
    1.84 +
    1.85  	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account);
    1.86  	if (convo) {
    1.87  		/* This is a channel we're already in; for some reason,
    1.88 @@ -1340,6 +1362,8 @@
    1.89  	struct irc_buddy *ib;
    1.90  	char *data[2];
    1.91  
    1.92 +	g_return_if_fail(gc);
    1.93 +
    1.94  	data[0] = irc_mask_nick(from);
    1.95  	data[1] = args[0];
    1.96  	/* XXX this should have an API, I shouldn't grab this directly */
    1.97 @@ -1366,6 +1390,8 @@
    1.98  	PurpleConnection *gc = purple_account_get_connection(irc->account);
    1.99  	char *nick, *msg;
   1.100  
   1.101 +	g_return_if_fail(gc);
   1.102 +
   1.103  	nick = irc_mask_nick(from);
   1.104  	msg = g_strdup_printf (_("Wallops from %s"), nick);
   1.105  	g_free(nick);