diff options
author | Stephen Swaney <sswaney@centurytel.net> | 2005-01-25 09:05:17 +0300 |
---|---|---|
committer | Stephen Swaney <sswaney@centurytel.net> | 2005-01-25 09:05:17 +0300 |
commit | c153a593ac9f590f31be17d798a0ce341e47a34b (patch) | |
tree | 102768fa0de3892a57756d4c235ee8003549a66e /source/blender/python/api2_2x/Bone.c | |
parent | 1b1ff7ea92a7cbe41139b74812fff108d2785b3e (diff) |
bugfix: #2117 Overflow in Armature.Bone.setName()
contributed by Joilnen B. Leite (pidhash).
Diffstat (limited to 'source/blender/python/api2_2x/Bone.c')
-rw-r--r-- | source/blender/python/api2_2x/Bone.c | 13 |
1 files changed, 11 insertions, 2 deletions
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 ); } |