pidgin/pidgin

Add back some checks for gc!=NULL.
release-2.x.y
2014-01-18, Mark Doliner
7d0fb0c6d8d4
Parents 4d9be297d399
Children 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.
--- a/libpurple/protocols/irc/msgs.c Sat Jan 18 10:21:44 2014 -0800
+++ b/libpurple/protocols/irc/msgs.c Sat Jan 18 10:22:41 2014 -0800
@@ -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 @@
{
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 @@
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 @@
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 @@
{
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 @@
{
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 @@
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 @@
{
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 @@
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 @@
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 @@
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);