comparison libpurple/plugins/tcl/tcl_ref.c @ 31772:d5a00aa868f3

Fix up several Tcl loader string copies to use g_strlcpy(). Thanks to the Electronic Frontier Foundation (https://www.eff.org/) for the foundation of this patch.
author Ethan Blanton <elb@pidgin.im>
date Sun, 17 Jul 2011 17:34:55 +0000
parents a8cc50c2279f
children
comparison
equal deleted inserted replaced
31771:680bd9ef2d8f 31772:d5a00aa868f3
90 OBJ_REF_VALUE(obj2) = OBJ_REF_VALUE(obj1); 90 OBJ_REF_VALUE(obj2) = OBJ_REF_VALUE(obj1);
91 } 91 }
92 92
93 static void purple_tcl_ref_update(Tcl_Obj *obj) 93 static void purple_tcl_ref_update(Tcl_Obj *obj)
94 { 94 {
95 size_t len;
95 /* This is ugly on memory, but we pretty much have to either 96 /* This is ugly on memory, but we pretty much have to either
96 * do this or guesstimate lengths or introduce a varargs 97 * do this or guesstimate lengths or introduce a varargs
97 * function in here ... ugh. */ 98 * function in here ... ugh. */
98 char *bytes = g_strdup_printf("purple-%s:%p", 99 char *bytes = g_strdup_printf("purple-%s:%p",
99 purple_stringref_value(OBJ_REF_TYPE(obj)), 100 purple_stringref_value(OBJ_REF_TYPE(obj)),
100 OBJ_REF_VALUE(obj)); 101 OBJ_REF_VALUE(obj));
101 102
102 obj->length = strlen(bytes); 103 obj->length = strlen(bytes);
103 obj->bytes = ckalloc(obj->length + 1); 104 len = obj->length + 1;
104 strcpy(obj->bytes, bytes); 105 obj->bytes = ckalloc(len);
106 g_strlcpy(obj->bytes, bytes, len);
105 g_free(bytes); 107 g_free(bytes);
106 } 108 }
107 109
108 /* This isn't as memory-efficient as setting could be, because we 110 /* This isn't as memory-efficient as setting could be, because we
109 * essentially have to synthesize the Stringref here, where we would 111 * essentially have to synthesize the Stringref here, where we would