changeset 31556:4b101cad58e7

Don't crash on invalid/unexpected jingle transport types. Fixes #13136. committer: John Bailey <rekkanoryo@rekkanoryo.org>
author nikita@beem-project.com
date Sat, 08 Jan 2011 02:58:06 +0000
parents 4f89666c8d81
children e71f78f10ce8
files libpurple/protocols/jabber/jingle/content.c libpurple/protocols/jabber/jingle/jingle.c libpurple/protocols/jabber/jingle/transport.c
diffstat 3 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jingle/content.c	Sat Jan 08 02:34:47 2011 +0000
+++ b/libpurple/protocols/jabber/jingle/content.c	Sat Jan 08 02:58:06 2011 +0000
@@ -384,6 +384,8 @@
 	const gchar *name = xmlnode_get_attrib(content, "name");
 	JingleTransport *transport =
 			jingle_transport_parse(xmlnode_get_child(content, "transport"));
+	if (transport == NULL)
+		return NULL;
 
 	if (senders == NULL)
 		senders = "both";
--- a/libpurple/protocols/jabber/jingle/jingle.c	Sat Jan 08 02:34:47 2011 +0000
+++ b/libpurple/protocols/jabber/jingle/jingle.c	Sat Jan 08 02:58:06 2011 +0000
@@ -42,6 +42,9 @@
 GType
 jingle_get_type(const gchar *type)
 {
+	if (type == NULL)
+		return G_TYPE_NONE;
+
 	if (!strcmp(type, JINGLE_TRANSPORT_RAWUDP))
 		return JINGLE_TYPE_RAWUDP;
 	else if (!strcmp(type, JINGLE_TRANSPORT_ICEUDP))
--- a/libpurple/protocols/jabber/jingle/transport.c	Sat Jan 08 02:34:47 2011 +0000
+++ b/libpurple/protocols/jabber/jingle/transport.c	Sat Jan 08 02:58:06 2011 +0000
@@ -159,8 +159,12 @@
 JingleTransport *
 jingle_transport_parse(xmlnode *transport)
 {
-	const gchar *type = xmlnode_get_namespace(transport);
-	return JINGLE_TRANSPORT_CLASS(g_type_class_ref(jingle_get_type(type)))->parse(transport);
+	const gchar *type_name = xmlnode_get_namespace(transport);
+	GType type = jingle_get_type(type_name);
+	if (type == G_TYPE_NONE)
+		return NULL;
+	
+	return JINGLE_TRANSPORT_CLASS(g_type_class_ref(type))->parse(transport);
 }
 
 xmlnode *