pidgin: c98f3283: Bounds-check stringref copies (which are...

elb at pidgin.im elb at pidgin.im
Wed Aug 17 20:01:02 EDT 2011


----------------------------------------------------------------------
Revision: c98f3283b77d14696b306f6992f206d50f14b2c6
Parent:   5b939418dcdb2654857fed5fa53fcae5e9390605
Author:   elb at pidgin.im
Date:     08/17/11 19:54:59
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/c98f3283b77d14696b306f6992f206d50f14b2c6

Changelog: 

Bounds-check stringref copies (which are safe anyway)

Changes against parent 5b939418dcdb2654857fed5fa53fcae5e9390605

  patched  libpurple/stringref.c

-------------- next part --------------
============================================================
--- libpurple/stringref.c	4b4950f45060e5c4738fa48ef2dbb60655b2075e
+++ libpurple/stringref.c	4f08269609ad7a209ecfdde0a06b38d84e8680de
@@ -65,12 +65,15 @@ PurpleStringref *purple_stringref_new(co
 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;


More information about the Commits mailing list