changeset 32265:b24babbae157

Bounds-check stringref copies (which are safe anyway)
author Ethan Blanton <elb@pidgin.im>
date Wed, 17 Aug 2011 23:54:59 +0000
parents 49d6ee09c74d
children f488952cc310
files libpurple/stringref.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/stringref.c	Wed Aug 17 22:00:37 2011 +0000
+++ b/libpurple/stringref.c	Wed Aug 17 23:54:59 2011 +0000
@@ -65,12 +65,15 @@
 PurpleStringref *purple_stringref_new(const char *value)
 {
 	PurpleStringref *newref;
+	size_t len;
 
 	if (value == NULL)
 		return NULL;
 
-	newref = g_malloc(sizeof(PurpleStringref) + strlen(value));
-	strcpy(newref->value, value);
+	len = strlen(value);
+
+	newref = g_malloc(sizeof(PurpleStringref) + len);
+	g_strlcpy(newref->value, value, len);
 	newref->ref = 1;
 
 	return newref;