changeset 25558:d8ce4de7137f

Prevent a NUL ptr deref when the passport is malformed. This came out of the veracode analysis.
author Daniel Atallah <daniel.atallah@gmail.com>
date Sat, 02 May 2009 19:33:22 +0000
parents fbcb4088d923
children 5e6999b6b5e4
files libpurple/protocols/msn/oim.c
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/oim.c	Sat May 02 19:21:11 2009 +0000
+++ b/libpurple/protocols/msn/oim.c	Sat May 02 19:33:22 2009 +0000
@@ -668,9 +668,15 @@
 		if (tokens[1] != NULL)
 			from = (const char *)tokens[1];
 
-		start = strchr(from, '<') + 1;
-		end = strchr(from, '>');
-		passport = g_strndup(start, end - start);
+		start = strchr(from, '<');
+		if (start != NULL) {
+			start++;
+			end = strchr(from, '>');
+			if (end != NULL)
+				passport = g_strndup(start, end - start);
+		}
+		if (passport == NULL)
+			passport = g_strdup(_("Unknown"));
 
 		g_strfreev(tokens);
 	}