From c153a593ac9f590f31be17d798a0ce341e47a34b Mon Sep 17 00:00:00 2001 From: Stephen Swaney Date: Tue, 25 Jan 2005 06:05:17 +0000 Subject: bugfix: #2117 Overflow in Armature.Bone.setName() contributed by Joilnen B. Leite (pidhash). --- source/blender/python/api2_2x/Bone.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'source/blender/python/api2_2x/Bone.c') diff --git a/source/blender/python/api2_2x/Bone.c b/source/blender/python/api2_2x/Bone.c index ddca513c1aa..e8c0613d220 100644 --- a/source/blender/python/api2_2x/Bone.c +++ b/source/blender/python/api2_2x/Bone.c @@ -974,18 +974,27 @@ static PyObject *Bone_getChildren( BPy_Bone * self ) static PyObject *Bone_setName( BPy_Bone * self, PyObject * args ) { char *name; + char buf[25]; if( !PyArg_ParseTuple( args, "s", &name ) ) return ( EXPP_ReturnPyObjError ( PyExc_AttributeError, "expected string argument" ) ); + /* + note: + a nicer way to do this is to have #defines for the size of names. + stivs 25-jan-200 + */ + + /* guarantee a null terminated string of reasonable size */ + PyOS_snprintf( buf, sizeof( buf ), "%s", name ); if( !self->bone ) { //test to see if linked to armature //use python vars - BLI_strncpy( self->name, name, strlen( name ) + 1 ); + BLI_strncpy( self->name, buf, sizeof( buf ) ); } else { //use bone datastruct - BLI_strncpy( self->bone->name, name, strlen( name ) + 1 ); + BLI_strncpy( self->bone->name, buf, sizeof( buf ) ); } return EXPP_incr_ret( Py_None ); } -- cgit v1.2.3