changeset 31335:2d029c5cd305

jabber: Protect against broken OSes and printf("%s", NULL) crashes
author Paul Aurich <paul@darkrain42.org>
date Tue, 02 Nov 2010 02:06:13 +0000
parents 5750f2f2cc0d
children e9e41a04513d
files libpurple/protocols/jabber/adhoccommands.c libpurple/protocols/jabber/presence.c
diffstat 2 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/adhoccommands.c	Tue Nov 02 01:57:06 2010 +0000
+++ b/libpurple/protocols/jabber/adhoccommands.c	Tue Nov 02 02:06:13 2010 +0000
@@ -125,7 +125,8 @@
 	xmlnode_set_attrib(command,"node",actionInfo->node);
 
 	/* cancel is handled differently on ad-hoc commands than regular forms */
-	if(!strcmp(xmlnode_get_namespace(result),"jabber:x:data") && !strcmp(xmlnode_get_attrib(result, "type"),"cancel")) {
+	if (purple_strequal(xmlnode_get_namespace(result), "jabber:x:data") &&
+			purple_strequal(xmlnode_get_attrib(result, "type"), "cancel")) {
 		xmlnode_set_attrib(command,"action","cancel");
 	} else {
 		if(actionhandle)
--- a/libpurple/protocols/jabber/presence.c	Tue Nov 02 01:57:06 2010 +0000
+++ b/libpurple/protocols/jabber/presence.c	Tue Nov 02 02:06:13 2010 +0000
@@ -995,12 +995,14 @@
 	}
 
 	for (child = packet->child; child; child = child->next) {
+		const char *xmlns;
 		char *key;
 		JabberPresenceHandler *pih;
 		if (child->type != XMLNODE_TYPE_TAG)
 			continue;
 
-		key = g_strdup_printf("%s %s", child->name, xmlnode_get_namespace(child));
+		xmlns = xmlnode_get_namespace(child);
+		key = g_strdup_printf("%s %s", child->name, xmlns ? xmlns : "");
 		pih = g_hash_table_lookup(presence_handlers, key);
 		g_free(key);
 		if (pih)