changeset 7933:f0784ce8189a

[gaim-migrate @ 8604] Although it's not supposed to be possible, someone had a crash from a truncated MSNObject string. This adds some extra safe-guards in parsing. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sat, 27 Dec 2003 00:31:43 +0000
parents 049443a8c76b
children 28609aa6c865
files src/protocols/msn/msnobject.c
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/msn/msnobject.c	Fri Dec 26 21:16:50 2003 +0000
+++ b/src/protocols/msn/msnobject.c	Sat Dec 27 00:31:43 2003 +0000
@@ -26,7 +26,8 @@
 	{ \
 		tag += strlen(id "=\""); \
 		c = strchr(tag, '"'); \
-		obj->field = g_strndup(tag, c - tag); \
+		if (c != NULL) \
+			obj->field = g_strndup(tag, c - tag); \
 	}
 
 #define GET_INT_TAG(field, id) \
@@ -35,8 +36,11 @@
 		char buf[16]; \
 		tag += strlen(id "=\""); \
 		c = strchr(tag, '"'); \
-		strncpy(buf, tag, c - tag); \
-		obj->field = atoi(buf); \
+		if (c != NULL) \
+		{ \
+			strncpy(buf, tag, c - tag); \
+			obj->field = atoi(buf); \
+		} \
 	}
 
 MsnObject *