another possible fix for bug [#29521], all callers of flip_side_name(...), assumed...
authorCampbell Barton <ideasman42@gmail.com>
Fri, 9 Dec 2011 07:35:56 +0000 (07:35 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 9 Dec 2011 07:35:56 +0000 (07:35 +0000)
in most cases the caller would then check if the name was different to see if the name was flipped, incorrectly comparing the uninitialized string with the original name.

source/blender/blenkernel/intern/deform.c
source/blender/editors/armature/editarmature.c
source/blender/editors/armature/poseobject.c
source/blender/editors/object/object_select.c

index 8dfd7e25bfb56663ece7a93275ca56aef6543b0b..e5176663228e28a5f169a917875141bce28e0ce3 100644 (file)
@@ -410,11 +410,15 @@ void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_
        char    number[MAX_VGROUP_NAME]=  "";   /* The number extension string */
        char    *index=NULL;
 
-       len= BLI_strnlen(from_name, MAX_VGROUP_NAME);
-       if (len < 3) return; // we don't do names like .R or .L
-
+       /* always copy the name, since this can be called with an uninitialized string */
        BLI_strncpy(name, from_name, MAX_VGROUP_NAME);
 
+       len= BLI_strnlen(from_name, MAX_VGROUP_NAME);
+       if (len < 3) {
+               /* we don't do names like .R or .L */
+               return;
+       }
+
        /* We first check the case with a .### extension, let's find the last period */
        if (isdigit(name[len-1])) {
                index= strrchr(name, '.'); // last occurrence
index caffdc291184cbf6601e2751cbc57cc5639cc385..6dbb08e115fa29a40f908b27b3b013bada459dc9 100644 (file)
@@ -161,7 +161,7 @@ void ED_armature_edit_bone_remove(bArmature *arm, EditBone *exBone)
 EditBone *ED_armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo)
 {
        EditBone *eboflip= NULL;
-       char name[32];
+       char name[MAXBONENAME];
        
        if (ebo == NULL)
                return NULL;
@@ -4663,7 +4663,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
                
                /* find flipped group */
                if (dgroup && mirror) {
-                       char name[32];
+                       char name[MAXBONENAME];
 
                        // 0 = don't strip off number extensions
                        flip_side_name(name, dgroup->name, FALSE);
@@ -5456,7 +5456,7 @@ static int armature_flip_names_exec (bContext *C, wmOperator *UNUSED(op))
 {
        Object *ob= CTX_data_edit_object(C);
        bArmature *arm;
-       char newname[32];
+       char newname[MAXBONENAME];
        
        /* paranoia checks */
        if (ELEM(NULL, ob, ob->pose)) 
index 993c8420576b899035b69d27df8fad2317b901e2..8d35122650f457bcafdd6df44e3bf691fdb4b692 100644 (file)
@@ -989,7 +989,7 @@ static void set_pose_keys (Object *ob)
 static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short selOnly, short flip)
 {
        bPoseChannel *pchan;
-       char name[32];
+       char name[MAXBONENAME];
        short paste_ok;
        
        /* get the name - if flipping, we must flip this first */
@@ -1740,7 +1740,7 @@ static int pose_flip_names_exec (bContext *C, wmOperator *UNUSED(op))
        /* loop through selected bones, auto-naming them */
        CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones)
        {
-               char newname[32];
+               char newname[MAXBONENAME];
                flip_side_name(newname, pchan->name, TRUE);
                ED_armature_bone_rename(arm, pchan->name, newname);
        }
index fce37b7a0229fbda024d736bbcc48d596358226a..c4d33b745748ef7b2601e7e67fd7448fed310310 100644 (file)
@@ -41,6 +41,7 @@
 #include "DNA_modifier_types.h"
 #include "DNA_property_types.h"
 #include "DNA_scene_types.h"
+#include "DNA_armature_types.h"
 
 #include "BLI_math.h"
 #include "BLI_listbase.h"
@@ -893,7 +894,7 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op)
        extend= RNA_boolean_get(op->ptr, "extend");
        
        CTX_DATA_BEGIN(C, Base*, primbase, selected_bases) {
-               char tmpname[32];
+               char tmpname[MAXBONENAME];
 
                flip_side_name(tmpname, primbase->object->id.name+2, TRUE);