constraints unique name length was set too long (could overrun the buffer), use sizeof() with other instances of BLI_uniquename too

This commit is contained in:
2010-02-18 10:14:49 +00:00
parent cff0110d08
commit 42fd22531f
12 changed files with 19 additions and 19 deletions

View File

@@ -748,7 +748,7 @@ void pose_add_group (Object *ob)
grp= MEM_callocN(sizeof(bActionGroup), "PoseGroup");
strcpy(grp->name, "Group");
BLI_addtail(&pose->agroups, grp);
BLI_uniquename(&pose->agroups, grp, "Group", '.', offsetof(bActionGroup, name), 32);
BLI_uniquename(&pose->agroups, grp, "Group", '.', offsetof(bActionGroup, name), sizeof(grp->name));
pose->active_group= BLI_countlist(&pose->agroups);
}

View File

@@ -604,7 +604,7 @@ KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, sho
ks= MEM_callocN(sizeof(KeyingSet), "KeyingSet");
if (name)
BLI_snprintf(ks->name, 64, name);
strncpy(ks->name, name, sizeof(ks->name));
else
strcpy(ks->name, "KeyingSet");
@@ -615,7 +615,7 @@ KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, sho
BLI_addtail(list, ks);
/* make sure KeyingSet has a unique name (this helps with identification) */
BLI_uniquename(list, ks, "KeyingSet", '.', offsetof(KeyingSet, name), 64);
BLI_uniquename(list, ks, "KeyingSet", '.', offsetof(KeyingSet, name), sizeof(ks->name));
/* return new KeyingSet for further editing */
return ks;

View File

@@ -96,7 +96,7 @@
/* Find the first available, non-duplicate name for a given constraint */
void unique_constraint_name (bConstraint *con, ListBase *list)
{
BLI_uniquename(list, con, "Const", '.', offsetof(bConstraint, name), 32);
BLI_uniquename(list, con, "Const", '.', offsetof(bConstraint, name), sizeof(con->name));
}
/* ----------------- Evaluation Loop Preparation --------------- */

View File

@@ -1199,7 +1199,7 @@ DriverVar *driver_add_new_variable (ChannelDriver *driver)
/* give the variable a 'unique' name */
strcpy(dvar->name, "var");
BLI_uniquename(&driver->variables, dvar, "var", '_', offsetof(DriverVar, name), 64);
BLI_uniquename(&driver->variables, dvar, "var", '_', offsetof(DriverVar, name), sizeof(dvar->name));
/* set the default type to 'single prop' */
driver_change_variable_type(dvar, DVAR_TYPE_SINGLE_PROP);

View File

@@ -194,7 +194,7 @@ bGPDlayer *gpencil_layer_addnew (bGPdata *gpd)
/* auto-name */
sprintf(gpl->info, "GP_Layer");
BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info[0]), 128);
BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info[0]), sizeof(gpl->info));
/* make this one the active one */
gpencil_layer_setactive(gpd, gpl);

View File

@@ -1101,10 +1101,10 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c
agrp->flag = AGRP_SELECTED;
if(muteipo) agrp->flag |= AGRP_MUTED;
BLI_snprintf(agrp->name, 64, grpname);
strncpy(agrp->name, grpname, sizeof(agrp->name));
BLI_addtail(&tmp_act.groups, agrp);
BLI_uniquename(&tmp_act.groups, agrp, "Group", '.', offsetof(bActionGroup, name), 64);
BLI_uniquename(&tmp_act.groups, agrp, "Group", '.', offsetof(bActionGroup, name), sizeof(agrp->name));
}
}

View File

@@ -258,8 +258,8 @@ NlaTrack *add_nlatrack (AnimData *adt, NlaTrack *prev)
BKE_nlatrack_set_active(&adt->nla_tracks, nlt);
/* must have unique name, but we need to seed this */
sprintf(nlt->name, "NlaTrack");
BLI_uniquename(&adt->nla_tracks, nlt, "NlaTrack", '.', offsetof(NlaTrack, name), 64);
strcpy(nlt->name, "NlaTrack");
BLI_uniquename(&adt->nla_tracks, nlt, "NlaTrack", '.', offsetof(NlaTrack, name), sizeof(nlt->name));
/* return the new track */
return nlt;

View File

@@ -909,7 +909,7 @@ void nodeAddSockets(bNode *node, bNodeType *ntype)
/* Find the first available, non-duplicate name for a given node */
void nodeUniqueName(bNodeTree *ntree, bNode *node)
{
BLI_uniquename(&ntree->nodes, node, "Node", '.', offsetof(bNode, name), 32);
BLI_uniquename(&ntree->nodes, node, "Node", '.', offsetof(bNode, name), sizeof(node->name));
}
bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup, ID *id)

View File

@@ -947,8 +947,8 @@ void scene_add_render_layer(Scene *sce)
// int tot= 1 + BLI_countlist(&sce->r.layers);
srl= MEM_callocN(sizeof(SceneRenderLayer), "new render layer");
sprintf(srl->name, "RenderLayer");
BLI_uniquename(&sce->r.layers, srl, "RenderLayer", '.', offsetof(SceneRenderLayer, name), 32);
strcpy(srl->name, "RenderLayer");
BLI_uniquename(&sce->r.layers, srl, "RenderLayer", '.', offsetof(SceneRenderLayer, name), sizeof(srl->name));
BLI_addtail(&sce->r.layers, srl);
/* note, this is also in render, pipeline.c, to make layer when scenedata doesnt have it */

View File

@@ -187,10 +187,10 @@ FCurve *verify_fcurve (bAction *act, const char group[], const char rna_path[],
grp= MEM_callocN(sizeof(bActionGroup), "bActionGroup");
grp->flag = AGRP_SELECTED;
BLI_snprintf(grp->name, 64, group);
strncpy(grp->name, group, sizeof(grp->name));
BLI_addtail(&act->groups, grp);
BLI_uniquename(&act->groups, grp, "Group", '.', offsetof(bActionGroup, name), 64);
BLI_uniquename(&act->groups, grp, "Group", '.', offsetof(bActionGroup, name), sizeof(grp->name));
}
/* add F-Curve to group */

View File

@@ -373,7 +373,7 @@ static int poselib_add_exec (bContext *C, wmOperator *op)
}
/* validate name */
BLI_uniquename(&act->markers, marker, "Pose", '.', offsetof(TimeMarker, name), 64);
BLI_uniquename(&act->markers, marker, "Pose", '.', offsetof(TimeMarker, name), sizeof(marker->name));
/* init common-key-source for use by KeyingSets */
memset(&cks, 0, sizeof(bCommonKeySrc));
@@ -578,7 +578,7 @@ static int poselib_rename_exec (bContext *C, wmOperator *op)
/* copy name and validate it */
BLI_strncpy(marker->name, newname, sizeof(marker->name));
BLI_uniquename(&act->markers, marker, "Pose", '.', offsetof(TimeMarker, name), 64);
BLI_uniquename(&act->markers, marker, "Pose", '.', offsetof(TimeMarker, name), sizeof(marker->name));
/* done */
return OPERATOR_FINISHED;

View File

@@ -4885,7 +4885,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
Object *ob= (Object *)tselem->id; // id = object
bActionGroup *grp= te->directdata;
BLI_uniquename(&ob->pose->agroups, grp, "Group", '.', offsetof(bActionGroup, name), 32);
BLI_uniquename(&ob->pose->agroups, grp, "Group", '.', offsetof(bActionGroup, name), sizeof(grp->name));
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
}
break;