pidgin: 4a49d2ab: Fix up several Tcl loader string copies ...

elb at pidgin.im elb at pidgin.im
Thu Aug 11 10:51:32 EDT 2011


----------------------------------------------------------------------
Revision: 4a49d2abc46efcf9db5e75e57a295cf4dcf88f8b
Parent:   85ba672811d9257624fddaf458d25014e3e48f0d
Author:   elb at pidgin.im
Date:     07/17/11 13:34:55
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/4a49d2abc46efcf9db5e75e57a295cf4dcf88f8b

Changelog: 

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.

Changes against parent 85ba672811d9257624fddaf458d25014e3e48f0d

  patched  libpurple/plugins/tcl/tcl_ref.c
  patched  libpurple/plugins/tcl/tcl_signals.c

-------------- next part --------------
============================================================
--- libpurple/plugins/tcl/tcl_signals.c	35c2b78eec9e14c1aa94c1baee307def79459d06
+++ libpurple/plugins/tcl/tcl_signals.c	9d8cec55dedaa2bbc5e1d24ea03cf9adf7bd0fbc
@@ -259,8 +259,9 @@ static void *tcl_signal_callback(va_list
 					vals[i] = ckalloc(1);
 					*(char *)vals[i] = '\0';
 				} else {
-					vals[i] = ckalloc(strlen(*strs[i]) + 1);
-					strcpy(vals[i], *strs[i]);
+					size_t len = strlen(*strs[i]) + 1;
+					vals[i] = ckalloc(len);
+					g_strlcpy(vals[i], *strs[i], len);
 				}
 				Tcl_LinkVar(handler->interp, name->str,
 					    (char *)&vals[i], TCL_LINK_STRING);
============================================================
--- libpurple/plugins/tcl/tcl_ref.c	110472d623d581203399513985f724c71e4b8933
+++ libpurple/plugins/tcl/tcl_ref.c	5b038a6a63b8fda3188df7b788635ef4bd55ad62
@@ -92,6 +92,7 @@ static void purple_tcl_ref_update(Tcl_Ob
 
 static void purple_tcl_ref_update(Tcl_Obj *obj)
 {
+	size_t len;
 	/* This is ugly on memory, but we pretty much have to either
 	 * do this or guesstimate lengths or introduce a varargs
 	 * function in here ... ugh. */
@@ -100,8 +101,9 @@ static void purple_tcl_ref_update(Tcl_Ob
 				      OBJ_REF_VALUE(obj));
 
 	obj->length = strlen(bytes);
-	obj->bytes = ckalloc(obj->length + 1);
-	strcpy(obj->bytes, bytes);
+	len = obj->length + 1;
+	obj->bytes = ckalloc(len);
+	g_strlcpy(obj->bytes, bytes, len);
 	g_free(bytes);
 }
 


More information about the Commits mailing list