Cleanup: remove strcpy usage

This commit is contained in:
Campbell Barton
2023-06-19 20:06:55 +10:00
parent 4a3b6bfeac
commit 8bcad285de
49 changed files with 168 additions and 171 deletions

View File

@@ -584,13 +584,14 @@ char *GHOST_GetTitle(GHOST_WindowHandle windowhandle)
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
std::string title = window->getTitle();
char *ctitle = (char *)malloc(title.size() + 1);
const size_t ctitle_size = title.size() + 1;
char *ctitle = (char *)malloc(ctitle_size);
if (ctitle == nullptr) {
return nullptr;
}
strcpy(ctitle, title.c_str());
memcpy(ctitle, title.c_str(), ctitle_size);
return ctitle;
}

View File

@@ -2190,12 +2190,14 @@ char *GHOST_SystemX11::getClipboard(bool selection) const
owner = XGetSelectionOwner(m_display, sseln);
if (owner == win) {
if (sseln == m_atom.CLIPBOARD) {
sel_buf = (char *)malloc(strlen(txt_cut_buffer) + 1);
strcpy(sel_buf, txt_cut_buffer);
size_t sel_buf_size = strlen(txt_cut_buffer) + 1;
sel_buf = (char *)malloc(sel_buf_size);
memcpy(sel_buf, txt_cut_buffer, sel_buf_size);
return sel_buf;
}
sel_buf = (char *)malloc(strlen(txt_select_buffer) + 1);
strcpy(sel_buf, txt_select_buffer);
size_t sel_buf_size = strlen(txt_select_buffer) + 1;
sel_buf = (char *)malloc(sel_buf_size);
memcpy(sel_buf, txt_select_buffer, sel_buf_size);
return sel_buf;
}
if (owner == None) {
@@ -2289,8 +2291,9 @@ void GHOST_SystemX11::putClipboard(const char *buffer, bool selection) const
free((void *)txt_cut_buffer);
}
txt_cut_buffer = (char *)malloc(strlen(buffer) + 1);
strcpy(txt_cut_buffer, buffer);
size_t buffer_size = strlen(buffer) + 1;
txt_cut_buffer = (char *)malloc(buffer_size);
memcpy(txt_cut_buffer, buffer, buffer_size);
}
else {
XSetSelectionOwner(m_display, m_atom.PRIMARY, m_window, CurrentTime);
@@ -2299,8 +2302,9 @@ void GHOST_SystemX11::putClipboard(const char *buffer, bool selection) const
free((void *)txt_select_buffer);
}
txt_select_buffer = (char *)malloc(strlen(buffer) + 1);
strcpy(txt_select_buffer, buffer);
size_t buffer_size = strlen(buffer) + 1;
txt_select_buffer = (char *)malloc(buffer_size);
memcpy(txt_select_buffer, buffer, buffer_size);
}
if (owner != m_window) {

View File

@@ -355,9 +355,9 @@ class BKE_armature_find_selected_bones_test : public testing::Test {
void SetUp() override
{
strcpy(bone1.name, "bone1");
strcpy(bone2.name, "bone2");
strcpy(bone3.name, "bone3");
STRNCPY(bone1.name, "bone1");
STRNCPY(bone2.name, "bone2");
STRNCPY(bone3.name, "bone3");
arm.bonebase = {nullptr, nullptr};
bone1.childbase = {nullptr, nullptr};

View File

@@ -147,7 +147,7 @@ void BKE_blender_globals_init(void)
BKE_blender_globals_main_replace(BKE_main_new());
strcpy(G.ima, "//");
STRNCPY(G.ima, "//");
#ifndef WITH_PYTHON_SECURITY /* default */
G.f |= G_FLAG_SCRIPT_AUTOEXEC;

View File

@@ -1657,7 +1657,7 @@ BoidState *boid_new_state(BoidSettings *boids)
SNPRINTF(state->name, "State %i", state->id);
}
else {
strcpy(state->name, "State");
STRNCPY(state->name, "State");
}
state->rule_fuzziness = 0.5;

View File

@@ -99,7 +99,7 @@ static void copy_lineset(FreestyleLineSet *new_lineset, FreestyleLineSet *linese
new_lineset->edge_types = lineset->edge_types;
new_lineset->exclude_edge_types = lineset->exclude_edge_types;
new_lineset->group = lineset->group;
strcpy(new_lineset->name, lineset->name);
STRNCPY(new_lineset->name, lineset->name);
if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
id_us_plus((ID *)new_lineset->linestyle);
@@ -187,7 +187,7 @@ FreestyleLineSet *BKE_freestyle_lineset_add(struct Main *bmain,
SNPRINTF(lineset->name, "LineSet %i", lineset_index + 1);
}
else {
strcpy(lineset->name, "LineSet");
STRNCPY(lineset->name, "LineSet");
}
BKE_freestyle_lineset_unique_name(config, lineset);

View File

@@ -791,7 +791,7 @@ IDProperty *IDP_GetProperties(ID *id, const bool create_if_needed)
/* NOTE(@ideasman42): Don't overwrite the data's name and type
* some functions might need this if they
* don't have a real ID, should be named elsewhere. */
// strcpy(id->name, "top_level_group");
// STRNCPY(id->name, "top_level_group");
}
return id->properties;
}

View File

@@ -1165,7 +1165,7 @@ static char *get_rna_access(ID *id,
else if ((blocktype == ID_KE) && STREQ(actname, "Shape")) {
/* Actionified "Shape" IPO's -
* these are forced onto object level via the action container there... */
strcpy(buf, "data.shape_keys");
STRNCPY(buf, "data.shape_keys");
}
else {
/* Pose-Channel */

View File

@@ -40,7 +40,7 @@ static void test_lattice_deform_init(LatticeDeformTestContext *ctx,
ctx->coords[index][2] = (rng->get_float() - 0.5f) * 10;
}
IDType_ID_LT.init_data(&ctx->lattice.id);
strcpy(ctx->lattice.id.name, "LTLattice");
STRNCPY(ctx->lattice.id.name, "LTLattice");
IDType_ID_OB.init_data(&ctx->ob_lattice.id);
ctx->ob_lattice.type = OB_LATTICE;
ctx->ob_lattice.data = &ctx->lattice;

View File

@@ -1620,7 +1620,7 @@ bool BKE_id_new_name_validate(
result = BKE_main_namemap_get_name(bmain, id, name);
strcpy(id->name + 2, name);
BLI_strncpy(id->name + 2, name, sizeof(id->name) - 2);
id_sort_by_name(lb, id, NULL);
return result;
}
@@ -2012,7 +2012,7 @@ void BKE_libblock_rename(Main *bmain, ID *id, const char *name)
void BKE_id_full_name_get(char name[MAX_ID_FULL_NAME], const ID *id, char separator_char)
{
strcpy(name, id->name + 2);
BLI_strncpy(name, id->name + 2, MAX_ID_FULL_NAME);
if (ID_IS_LINKED(id)) {
const size_t idname_len = strlen(id->name + 2);
@@ -2020,7 +2020,7 @@ void BKE_id_full_name_get(char name[MAX_ID_FULL_NAME], const ID *id, char separa
name[idname_len] = separator_char ? separator_char : ' ';
name[idname_len + 1] = '[';
strcpy(name + idname_len + 2, id->lib->id.name + 2);
BLI_strncpy(name + idname_len + 2, id->lib->id.name + 2, MAX_ID_FULL_NAME - (idname_len + 2));
name[idname_len + 2 + libname_len] = ']';
name[idname_len + 2 + libname_len + 1] = '\0';
}

View File

@@ -336,12 +336,7 @@ MaskLayer *BKE_mask_layer_new(Mask *mask, const char *name)
{
MaskLayer *masklay = MEM_cnew<MaskLayer>(__func__);
if (name && name[0]) {
STRNCPY(masklay->name, name);
}
else {
strcpy(masklay->name, DATA_("MaskLayer"));
}
STRNCPY(masklay->name, name && name[0] ? name : DATA_("MaskLayer"));
BLI_addtail(&mask->masklayers, masklay);
@@ -1011,12 +1006,7 @@ Mask *BKE_mask_new(Main *bmain, const char *name)
Mask *mask;
char mask_name[MAX_ID_NAME - 2];
if (name && name[0]) {
STRNCPY(mask_name, name);
}
else {
strcpy(mask_name, "Mask");
}
STRNCPY(mask_name, (name && name[0]) ? name : "Mask");
mask = mask_alloc(bmain, mask_name);
@@ -2040,7 +2030,7 @@ void BKE_mask_clipboard_copy_from_layer(MaskLayer *mask_layer)
if (!BLI_ghash_lookup(mask_clipboard.id_hash, point->parent.id)) {
int len = strlen(point->parent.id->name);
char *name_copy = static_cast<char *>(MEM_mallocN(len + 1, "mask clipboard ID name"));
strcpy(name_copy, point->parent.id->name);
memcpy(name_copy, point->parent.id->name, len + 1);
BLI_ghash_insert(mask_clipboard.id_hash, point->parent.id, name_copy);
}
}

View File

@@ -338,14 +338,16 @@ void BKE_mesh_calc_loop_tangent_step_0(const CustomData *loopData,
*ract_uv_n = CustomData_get_active_layer(loopData, CD_PROP_FLOAT2);
ract_uv_name[0] = 0;
if (*ract_uv_n != -1) {
strcpy(ract_uv_name, loopData->layers[*ract_uv_n + layer_index].name);
BLI_strncpy(
ract_uv_name, loopData->layers[*ract_uv_n + layer_index].name, MAX_CUSTOMDATA_LAYER_NAME);
}
/* Active tangent in render */
*rren_uv_n = CustomData_get_render_layer(loopData, CD_PROP_FLOAT2);
rren_uv_name[0] = 0;
if (*rren_uv_n != -1) {
strcpy(rren_uv_name, loopData->layers[*rren_uv_n + layer_index].name);
BLI_strncpy(
rren_uv_name, loopData->layers[*rren_uv_n + layer_index].name, MAX_CUSTOMDATA_LAYER_NAME);
}
/* If active tangent not in tangent_names we take it into account */

View File

@@ -367,7 +367,7 @@ void BKE_nlatrack_insert_before(ListBase *nla_tracks,
new_track->index = BLI_findindex(nla_tracks, new_track);
/* Must have unique name, but we need to seed this. */
strcpy(new_track->name, "NlaTrack");
STRNCPY(new_track->name, "NlaTrack");
BLI_uniquename(nla_tracks,
new_track,

View File

@@ -1424,14 +1424,15 @@ static int ptcache_filepath(PTCacheID *pid,
idname = (pid->owner_id->name + 2);
/* convert chars to hex so they are always a valid filename */
while ('\0' != *idname) {
BLI_snprintf(newname, MAX_PTCACHE_FILE - len, "%02X", (uint)(*idname++));
newname += 2;
len += 2;
/* Always 2 unless there isn't enough room in the string. */
const int temp = BLI_snprintf_rlen(
newname, MAX_PTCACHE_FILE - len, "%02X", (uint)(*idname++));
newname += temp;
len += temp;
}
}
else {
int temp = (int)strlen(pid->cache->name);
strcpy(newname, pid->cache->name);
int temp = BLI_strncpy_rlen(newname, pid->cache->name, MAX_PTCACHE_FILE - len);
newname += temp;
len += temp;
}

View File

@@ -462,8 +462,7 @@ bSound *BKE_sound_new_buffer(Main *bmain, bSound *source)
bSound *sound = NULL;
char name[MAX_ID_NAME + 5];
strcpy(name, "buf_");
strcpy(name + 4, source->id.name);
BLI_string_join(name, sizeof(name), "buf_", source->id.name);
sound = BKE_libblock_alloc(bmain, ID_SO, name);
@@ -480,8 +479,7 @@ bSound *BKE_sound_new_limiter(Main *bmain, bSound *source, float start, float en
bSound *sound = NULL;
char name[MAX_ID_NAME + 5];
strcpy(name, "lim_");
strcpy(name + 4, source->id.name);
BLI_string_join(name, sizeof(name), "lim_", source->id.name);
sound = BKE_libblock_alloc(bmain, ID_SO, name);

View File

@@ -499,7 +499,7 @@ MovieTrackingTrack *BKE_tracking_track_add_empty(MovieTracking *tracking, ListBa
const MovieTrackingSettings *settings = &tracking->settings;
MovieTrackingTrack *track = MEM_cnew<MovieTrackingTrack>("add_marker_exec track");
strcpy(track->name, "Track");
STRNCPY(track->name, "Track");
/* Fill track's settings from default settings. */
track->motion_model = settings->default_motion_model;
@@ -1579,7 +1579,7 @@ MovieTrackingPlaneTrack *BKE_tracking_plane_track_add(MovieTracking *tracking,
plane_track = MEM_cnew<MovieTrackingPlaneTrack>("new plane track");
/* Use some default name. */
strcpy(plane_track->name, "Plane Track");
STRNCPY(plane_track->name, "Plane Track");
plane_track->image_opacity = 1.0f;

View File

@@ -295,7 +295,7 @@ static VFontData *vfont_get_data(VFont *vfont)
/* DON'T DO THIS
* missing file shouldn't modify path! - campbell */
#if 0
strcpy(vfont->filepath, FO_BUILTIN_NAME);
STRNCPY(vfont->filepath, FO_BUILTIN_NAME);
#endif
pf = get_builtin_packedfile();
}

View File

@@ -15,7 +15,7 @@
# include <dirent.h>
#endif
#include <string.h> /* #strcpy etc. */
#include <string.h>
#include <sys/stat.h>
#include <time.h>
@@ -320,7 +320,7 @@ void BLI_filelist_entry_owner_to_string(const struct stat *st,
{
#ifdef WIN32
UNUSED_VARS(st);
strcpy(r_owner, "unknown");
BLI_strncpy(r_owner, "unknown", FILELIST_DIRENTRY_OWNER_LEN);
#else
struct passwd *pwuser = getpwuid(st->st_uid);

View File

@@ -793,7 +793,7 @@ void BLI_path_rel(char path[FILE_MAX], const char *basepath)
#ifdef WIN32
BLI_str_replace_char(res + 2, '/', '\\');
#endif
strcpy(path, res);
BLI_strncpy(path, res, FILE_MAX);
}
}

View File

@@ -32,7 +32,7 @@
#endif
#include <fcntl.h>
#include <string.h> /* `strcpy` etc. */
#include <string.h>
#ifdef WIN32
# include "BLI_string_utf8.h"
@@ -145,16 +145,17 @@ double BLI_dir_free_space(const char *dir)
return -1;
}
strcpy(dirname, dir);
memcpy(dirname, dir, len + 1);
if (len) {
slash = strrchr(dirname, '/');
if (slash) {
slash[1] = 0;
slash[1] = '\0';
}
}
else {
strcpy(dirname, "/");
dirname[0] = '/';
dirname[1] = '\0';
}
# if defined(USE_STATFS_STATVFS)

View File

@@ -716,7 +716,7 @@ void blo_do_versions_250(FileData *fd, Library *UNUSED(lib), Main *bmain)
*/
for (ma = bmain->materials.first; ma; ma = ma->id.next) {
if (ma->nodetree && ma->nodetree->id.name[0] == '\0') {
strcpy(ma->nodetree->id.name, "NTShader Nodetree");
STRNCPY(ma->nodetree->id.name, "NTShader Nodetree");
}
}
@@ -724,7 +724,7 @@ void blo_do_versions_250(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (sce = bmain->scenes.first; sce; sce = sce->id.next) {
enum { R_PANORAMA = (1 << 10) };
if (sce->nodetree && sce->nodetree->id.name[0] == '\0') {
strcpy(sce->nodetree->id.name, "NTCompositing Nodetree");
STRNCPY(sce->nodetree->id.name, "NTCompositing Nodetree");
}
/* move to cameras */
@@ -748,7 +748,7 @@ void blo_do_versions_250(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (tx->nodetree) {
if (tx->nodetree->id.name[0] == '\0') {
strcpy(tx->nodetree->id.name, "NTTexture Nodetree");
STRNCPY(tx->nodetree->id.name, "NTTexture Nodetree");
}
/* which_output 0 is now "not specified" */
@@ -2315,7 +2315,7 @@ static void lib_node_do_versions_group_indices(bNode *gnode)
for (link = ngroup->links.first; link; link = link->next) {
if (link->tonode == NULL && link->fromsock->own_index == old_index) {
strcpy(sock->identifier, link->fromsock->identifier);
STRNCPY(sock->identifier, link->fromsock->identifier);
/* deprecated */
sock->own_index = link->fromsock->own_index;
sock->to_index = 0;
@@ -2327,7 +2327,7 @@ static void lib_node_do_versions_group_indices(bNode *gnode)
for (link = ngroup->links.first; link; link = link->next) {
if (link->fromnode == NULL && link->tosock->own_index == old_index) {
strcpy(sock->identifier, link->tosock->identifier);
STRNCPY(sock->identifier, link->tosock->identifier);
/* deprecated */
sock->own_index = link->tosock->own_index;
sock->to_index = 0;

View File

@@ -551,13 +551,13 @@ static void do_versions_nodetree_customnodes(bNodeTree *ntree, int UNUSED(is_gro
/* tree type idname */
switch (ntree->type) {
case NTREE_COMPOSIT:
strcpy(ntree->idname, "CompositorNodeTree");
STRNCPY(ntree->idname, "CompositorNodeTree");
break;
case NTREE_SHADER:
strcpy(ntree->idname, "ShaderNodeTree");
STRNCPY(ntree->idname, "ShaderNodeTree");
break;
case NTREE_TEXTURE:
strcpy(ntree->idname, "TextureNodeTree");
STRNCPY(ntree->idname, "TextureNodeTree");
break;
}
@@ -1947,13 +1947,13 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* convert deprecated treetype setting to tree_idname */
switch (snode->treetype) {
case NTREE_COMPOSIT:
strcpy(snode->tree_idname, "CompositorNodeTree");
STRNCPY(snode->tree_idname, "CompositorNodeTree");
break;
case NTREE_SHADER:
strcpy(snode->tree_idname, "ShaderNodeTree");
STRNCPY(snode->tree_idname, "ShaderNodeTree");
break;
case NTREE_TEXTURE:
strcpy(snode->tree_idname, "TextureNodeTree");
STRNCPY(snode->tree_idname, "TextureNodeTree");
break;
}
}

View File

@@ -1363,7 +1363,7 @@ static void version_switch_node_input_prefix(Main *bmain)
if (socket == node->inputs.first) {
continue;
}
strcpy(socket->name, socket->name[0] == 'A' ? "False" : "True");
STRNCPY(socket->name, socket->name[0] == 'A' ? "False" : "True");
/* Replace "A" and "B", but keep the unique number suffix at the end. */
char number_suffix[8];
@@ -1940,7 +1940,7 @@ static void versioning_replace_legacy_combined_and_separate_color_nodes(bNodeTre
NodeCombSepColor *storage = (NodeCombSepColor *)MEM_callocN(sizeof(NodeCombSepColor),
__func__);
storage->mode = NODE_COMBSEP_COLOR_RGB;
strcpy(node->idname, "FunctionNodeCombineColor");
STRNCPY(node->idname, "FunctionNodeCombineColor");
node->storage = storage;
break;
}
@@ -1949,7 +1949,7 @@ static void versioning_replace_legacy_combined_and_separate_color_nodes(bNodeTre
NodeCombSepColor *storage = (NodeCombSepColor *)MEM_callocN(sizeof(NodeCombSepColor),
__func__);
storage->mode = NODE_COMBSEP_COLOR_RGB;
strcpy(node->idname, "FunctionNodeSeparateColor");
STRNCPY(node->idname, "FunctionNodeSeparateColor");
node->storage = storage;
break;
}
@@ -2007,7 +2007,7 @@ static void versioning_replace_legacy_combined_and_separate_color_nodes(bNodeTre
NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)MEM_callocN(
sizeof(NodeCMPCombSepColor), __func__);
storage->mode = CMP_NODE_COMBSEP_COLOR_RGB;
strcpy(node->idname, "CompositorNodeCombineColor");
STRNCPY(node->idname, "CompositorNodeCombineColor");
node->storage = storage;
break;
}
@@ -2016,7 +2016,7 @@ static void versioning_replace_legacy_combined_and_separate_color_nodes(bNodeTre
NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)MEM_callocN(
sizeof(NodeCMPCombSepColor), __func__);
storage->mode = CMP_NODE_COMBSEP_COLOR_HSV;
strcpy(node->idname, "CompositorNodeCombineColor");
STRNCPY(node->idname, "CompositorNodeCombineColor");
node->storage = storage;
break;
}
@@ -2026,7 +2026,7 @@ static void versioning_replace_legacy_combined_and_separate_color_nodes(bNodeTre
sizeof(NodeCMPCombSepColor), __func__);
storage->mode = CMP_NODE_COMBSEP_COLOR_YCC;
storage->ycc_mode = node->custom1;
strcpy(node->idname, "CompositorNodeCombineColor");
STRNCPY(node->idname, "CompositorNodeCombineColor");
node->storage = storage;
break;
}
@@ -2035,7 +2035,7 @@ static void versioning_replace_legacy_combined_and_separate_color_nodes(bNodeTre
NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)MEM_callocN(
sizeof(NodeCMPCombSepColor), __func__);
storage->mode = CMP_NODE_COMBSEP_COLOR_YUV;
strcpy(node->idname, "CompositorNodeCombineColor");
STRNCPY(node->idname, "CompositorNodeCombineColor");
node->storage = storage;
break;
}
@@ -2044,7 +2044,7 @@ static void versioning_replace_legacy_combined_and_separate_color_nodes(bNodeTre
NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)MEM_callocN(
sizeof(NodeCMPCombSepColor), __func__);
storage->mode = CMP_NODE_COMBSEP_COLOR_RGB;
strcpy(node->idname, "CompositorNodeSeparateColor");
STRNCPY(node->idname, "CompositorNodeSeparateColor");
node->storage = storage;
break;
}
@@ -2053,7 +2053,7 @@ static void versioning_replace_legacy_combined_and_separate_color_nodes(bNodeTre
NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)MEM_callocN(
sizeof(NodeCMPCombSepColor), __func__);
storage->mode = CMP_NODE_COMBSEP_COLOR_HSV;
strcpy(node->idname, "CompositorNodeSeparateColor");
STRNCPY(node->idname, "CompositorNodeSeparateColor");
node->storage = storage;
break;
}
@@ -2063,7 +2063,7 @@ static void versioning_replace_legacy_combined_and_separate_color_nodes(bNodeTre
sizeof(NodeCMPCombSepColor), __func__);
storage->mode = CMP_NODE_COMBSEP_COLOR_YCC;
storage->ycc_mode = node->custom1;
strcpy(node->idname, "CompositorNodeSeparateColor");
STRNCPY(node->idname, "CompositorNodeSeparateColor");
node->storage = storage;
break;
}
@@ -2072,7 +2072,7 @@ static void versioning_replace_legacy_combined_and_separate_color_nodes(bNodeTre
NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)MEM_callocN(
sizeof(NodeCMPCombSepColor), __func__);
storage->mode = CMP_NODE_COMBSEP_COLOR_YUV;
strcpy(node->idname, "CompositorNodeSeparateColor");
STRNCPY(node->idname, "CompositorNodeSeparateColor");
node->storage = storage;
break;
}
@@ -2087,13 +2087,13 @@ static void versioning_replace_legacy_combined_and_separate_color_nodes(bNodeTre
case TEX_NODE_COMPOSE_LEGACY: {
node->type = TEX_NODE_COMBINE_COLOR;
node->custom1 = NODE_COMBSEP_COLOR_RGB;
strcpy(node->idname, "TextureNodeCombineColor");
STRNCPY(node->idname, "TextureNodeCombineColor");
break;
}
case TEX_NODE_DECOMPOSE_LEGACY: {
node->type = TEX_NODE_SEPARATE_COLOR;
node->custom1 = NODE_COMBSEP_COLOR_RGB;
strcpy(node->idname, "TextureNodeSeparateColor");
STRNCPY(node->idname, "TextureNodeSeparateColor");
break;
}
}
@@ -2127,7 +2127,7 @@ static void versioning_replace_legacy_combined_and_separate_color_nodes(bNodeTre
NodeCombSepColor *storage = (NodeCombSepColor *)MEM_callocN(sizeof(NodeCombSepColor),
__func__);
storage->mode = NODE_COMBSEP_COLOR_RGB;
strcpy(node->idname, "ShaderNodeCombineColor");
STRNCPY(node->idname, "ShaderNodeCombineColor");
node->storage = storage;
break;
}
@@ -2136,7 +2136,7 @@ static void versioning_replace_legacy_combined_and_separate_color_nodes(bNodeTre
NodeCombSepColor *storage = (NodeCombSepColor *)MEM_callocN(sizeof(NodeCombSepColor),
__func__);
storage->mode = NODE_COMBSEP_COLOR_HSV;
strcpy(node->idname, "ShaderNodeCombineColor");
STRNCPY(node->idname, "ShaderNodeCombineColor");
node->storage = storage;
break;
}
@@ -2145,7 +2145,7 @@ static void versioning_replace_legacy_combined_and_separate_color_nodes(bNodeTre
NodeCombSepColor *storage = (NodeCombSepColor *)MEM_callocN(sizeof(NodeCombSepColor),
__func__);
storage->mode = NODE_COMBSEP_COLOR_RGB;
strcpy(node->idname, "ShaderNodeSeparateColor");
STRNCPY(node->idname, "ShaderNodeSeparateColor");
node->storage = storage;
break;
}
@@ -2154,7 +2154,7 @@ static void versioning_replace_legacy_combined_and_separate_color_nodes(bNodeTre
NodeCombSepColor *storage = (NodeCombSepColor *)MEM_callocN(sizeof(NodeCombSepColor),
__func__);
storage->mode = NODE_COMBSEP_COLOR_HSV;
strcpy(node->idname, "ShaderNodeSeparateColor");
STRNCPY(node->idname, "ShaderNodeSeparateColor");
node->storage = storage;
break;
}
@@ -2171,7 +2171,7 @@ static void versioning_replace_legacy_mix_rgb_node(bNodeTree *ntree)
version_node_output_socket_name(ntree, SH_NODE_MIX_RGB_LEGACY, "Color", "Result_Color");
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_MIX_RGB_LEGACY) {
strcpy(node->idname, "ShaderNodeMix");
STRNCPY(node->idname, "ShaderNodeMix");
node->type = SH_NODE_MIX;
NodeShaderMix *data = (NodeShaderMix *)MEM_callocN(sizeof(NodeShaderMix), __func__);
data->blend_type = node->custom1;
@@ -2570,7 +2570,7 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
if (ntree->type == NTREE_GEOMETRY) {
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == GEO_NODE_SUBDIVIDE_MESH) {
strcpy(node->idname, "GeometryNodeMeshSubdivide");
STRNCPY(node->idname, "GeometryNodeMeshSubdivide");
}
}
}
@@ -3266,7 +3266,7 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
sizeof(NodeFunctionCompare), __func__);
data->data_type = SOCK_FLOAT;
data->operation = node->custom1;
strcpy(node->idname, "FunctionNodeCompare");
STRNCPY(node->idname, "FunctionNodeCompare");
node->storage = data;
}
}

View File

@@ -164,7 +164,7 @@ static void versioning_replace_legacy_glossy_node(bNodeTree *ntree)
{
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_BSDF_GLOSSY_LEGACY) {
strcpy(node->idname, "ShaderNodeBsdfAnisotropic");
STRNCPY(node->idname, "ShaderNodeBsdfAnisotropic");
node->type = SH_NODE_BSDF_GLOSSY;
}
}

View File

@@ -191,7 +191,7 @@ void version_node_id(bNodeTree *ntree, const int node_type, const char *new_name
for (bNode *node : ntree->all_nodes()) {
if (node->type == node_type) {
if (!STREQ(node->idname, new_name)) {
strcpy(node->idname, new_name);
STRNCPY(node->idname, new_name);
}
}
}

View File

@@ -1040,8 +1040,8 @@ static void update_voronoi_node_fac_output(bNodeTree *ntree)
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_TEX_VORONOI) {
bNodeSocket *facOutput = BLI_findlink(&node->outputs, 1);
strcpy(facOutput->identifier, "Distance");
strcpy(facOutput->name, "Distance");
STRNCPY(facOutput->identifier, "Distance");
STRNCPY(facOutput->name, "Distance");
}
}
}

View File

@@ -324,7 +324,7 @@ static void customdata_version_242(Mesh *me)
if (layer->type == CD_MTFACE) {
if (layer->name[0] == 0) {
if (mtfacen == 0) {
strcpy(layer->name, "UVMap");
STRNCPY(layer->name, "UVMap");
}
else {
SNPRINTF(layer->name, "UVMap.%.3d", mtfacen);
@@ -335,7 +335,7 @@ static void customdata_version_242(Mesh *me)
else if (layer->type == CD_MCOL) {
if (layer->name[0] == 0) {
if (mcoln == 0) {
strcpy(layer->name, "Col");
STRNCPY(layer->name, "Col");
}
else {
SNPRINTF(layer->name, "Col.%.3d", mcoln);
@@ -843,7 +843,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
VFont *vf;
for (vf = bmain->fonts.first; vf; vf = vf->id.next) {
if (BLI_str_endswith(vf->filepath, ".Bfont")) {
strcpy(vf->filepath, FO_BUILTIN_NAME);
STRNCPY(vf->filepath, FO_BUILTIN_NAME);
}
}
}
@@ -1476,7 +1476,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
for (kb = key->block.first; kb; kb = kb->next) {
if (kb == key->refkey) {
if (kb->name[0] == 0) {
strcpy(kb->name, "Basis");
STRNCPY(kb->name, "Basis");
}
}
else {
@@ -1611,8 +1611,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
Image *ima;
for (ima = bmain->images.first; ima; ima = ima->id.next) {
if (STREQ(ima->filepath, "Compositor")) {
strcpy(ima->id.name + 2, "Viewer Node");
strcpy(ima->filepath, "Viewer Node");
BLI_strncpy(ima->id.name + 2, "Viewer Node", sizeof(ima->id.name) - 2);
STRNCPY(ima->filepath, "Viewer Node");
}
}
}

View File

@@ -237,7 +237,7 @@ void blo_do_versions_userdef(UserDef *userdef)
}
if (!USER_VERSION_ATLEAST(192, 0)) {
strcpy(userdef->sounddir, "/");
STRNCPY(userdef->sounddir, "/");
}
/* patch to set Dupli Armature */
@@ -311,52 +311,52 @@ void blo_do_versions_userdef(UserDef *userdef)
for (km = userdef->user_keymaps.first; km; km = km->next) {
if (STREQ(km->idname, "Armature_Sketch")) {
strcpy(km->idname, "Armature Sketch");
STRNCPY(km->idname, "Armature Sketch");
}
else if (STREQ(km->idname, "View3D")) {
strcpy(km->idname, "3D View");
STRNCPY(km->idname, "3D View");
}
else if (STREQ(km->idname, "View3D Generic")) {
strcpy(km->idname, "3D View Generic");
STRNCPY(km->idname, "3D View Generic");
}
else if (STREQ(km->idname, "EditMesh")) {
strcpy(km->idname, "Mesh");
STRNCPY(km->idname, "Mesh");
}
else if (STREQ(km->idname, "UVEdit")) {
strcpy(km->idname, "UV Editor");
STRNCPY(km->idname, "UV Editor");
}
else if (STREQ(km->idname, "Animation_Channels")) {
strcpy(km->idname, "Animation Channels");
STRNCPY(km->idname, "Animation Channels");
}
else if (STREQ(km->idname, "GraphEdit Keys")) {
strcpy(km->idname, "Graph Editor");
STRNCPY(km->idname, "Graph Editor");
}
else if (STREQ(km->idname, "GraphEdit Generic")) {
strcpy(km->idname, "Graph Editor Generic");
STRNCPY(km->idname, "Graph Editor Generic");
}
else if (STREQ(km->idname, "Action_Keys")) {
strcpy(km->idname, "Dopesheet");
STRNCPY(km->idname, "Dopesheet");
}
else if (STREQ(km->idname, "NLA Data")) {
strcpy(km->idname, "NLA Editor");
STRNCPY(km->idname, "NLA Editor");
}
else if (STREQ(km->idname, "Node Generic")) {
strcpy(km->idname, "Node Editor");
STRNCPY(km->idname, "Node Editor");
}
else if (STREQ(km->idname, "Logic Generic")) {
strcpy(km->idname, "Logic Editor");
STRNCPY(km->idname, "Logic Editor");
}
else if (STREQ(km->idname, "File")) {
strcpy(km->idname, "File Browser");
STRNCPY(km->idname, "File Browser");
}
else if (STREQ(km->idname, "FileMain")) {
strcpy(km->idname, "File Browser Main");
STRNCPY(km->idname, "File Browser Main");
}
else if (STREQ(km->idname, "FileButtons")) {
strcpy(km->idname, "File Browser Buttons");
STRNCPY(km->idname, "File Browser Buttons");
}
else if (STREQ(km->idname, "Buttons Generic")) {
strcpy(km->idname, "Property Editor");
STRNCPY(km->idname, "Property Editor");
}
}
}

View File

@@ -104,7 +104,7 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count)
freestyle_scene->r.border.ymin = old_scene->r.border.ymin;
freestyle_scene->r.border.xmax = old_scene->r.border.xmax;
freestyle_scene->r.border.ymax = old_scene->r.border.ymax;
strcpy(freestyle_scene->r.pic, old_scene->r.pic);
STRNCPY(freestyle_scene->r.pic, old_scene->r.pic);
freestyle_scene->r.dither_intensity = old_scene->r.dither_intensity;
STRNCPY(freestyle_scene->r.engine, old_scene->r.engine);
if (G.debug & G_DEBUG_FREESTYLE) {

View File

@@ -708,7 +708,7 @@ void FRS_copy_active_lineset(FreestyleConfig *config)
lineset_buffer.edge_types = lineset->edge_types;
lineset_buffer.exclude_edge_types = lineset->exclude_edge_types;
lineset_buffer.group = lineset->group;
strcpy(lineset_buffer.name, lineset->name);
STRNCPY(lineset_buffer.name, lineset->name);
lineset_copied = true;
}
}
@@ -744,7 +744,7 @@ void FRS_paste_active_lineset(FreestyleConfig *config)
lineset->group = lineset_buffer.group;
id_us_plus(&lineset->group->id);
}
strcpy(lineset->name, lineset_buffer.name);
STRNCPY(lineset->name, lineset_buffer.name);
BKE_freestyle_lineset_unique_name(config, lineset);
lineset->flags |= FREESTYLE_LINESET_CURRENT;
}

View File

@@ -366,7 +366,7 @@ static void panelRegister(ARegionType *region_type)
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
uiListType *list_type = MEM_callocN(sizeof(uiListType), "dash modifier segment uilist");
strcpy(list_type->idname, "MOD_UL_dash_segment");
STRNCPY(list_type->idname, "MOD_UL_dash_segment");
list_type->draw_item = segment_list_item;
WM_uilisttype_add(list_type);
}

View File

@@ -417,7 +417,7 @@ static void panelRegister(ARegionType *region_type)
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
uiListType *list_type = MEM_callocN(sizeof(uiListType), "time modifier segment uilist");
strcpy(list_type->idname, "MOD_UL_time_segment");
STRNCPY(list_type->idname, "MOD_UL_time_segment");
list_type->draw_item = segment_list_item;
WM_uilisttype_add(list_type);
}

View File

@@ -52,7 +52,7 @@ static void fillDpxMainHeader(LogImageFile *dpx,
/* --- File header --- */
header->fileHeader.magic_num = swap_uint(DPX_FILE_MAGIC, dpx->isMSB);
header->fileHeader.offset = swap_uint(dpx->element[0].dataOffset, dpx->isMSB);
strcpy(header->fileHeader.version, "V2.0");
STRNCPY(header->fileHeader.version, "V2.0");
header->fileHeader.file_size = swap_uint(
dpx->element[0].dataOffset + dpx->height * getRowLength(dpx->width, dpx->element[0]),
dpx->isMSB);

View File

@@ -567,7 +567,7 @@ static void write_jpeg(jpeg_compress_struct *cinfo, ImBuf *ibuf)
jpeg_start_compress(cinfo, true);
strcpy(neogeo, "NeoGeo");
STRNCPY(neogeo, "NeoGeo");
neogeo_word = (NeoGeo_Word *)(neogeo + 6);
memset(neogeo_word, 0, sizeof(*neogeo_word));
neogeo_word->quality = ibuf->foptions.quality;

View File

@@ -1480,6 +1480,8 @@ static int imb_exr_split_token(const char *str, const char *end, const char **to
static int imb_exr_split_channel_name(ExrChannel *echan, char *layname, char *passname)
{
const int layname_maxncpy = EXR_TOT_MAXNAME;
const int passname_maxncpy = EXR_TOT_MAXNAME;
const char *name = echan->m->name.c_str();
const char *end = name + strlen(name);
const char *token;
@@ -1490,13 +1492,13 @@ static int imb_exr_split_channel_name(ExrChannel *echan, char *layname, char *pa
layname[0] = '\0';
if (ELEM(name[0], 'R', 'G', 'B', 'A')) {
strcpy(passname, "Combined");
BLI_strncpy(passname, "Combined", passname_maxncpy);
}
else if (name[0] == 'Z') {
strcpy(passname, "Depth");
BLI_strncpy(passname, "Depth", passname_maxncpy);
}
else {
strcpy(passname, name);
BLI_strncpy(passname, name, passname_maxncpy);
}
return 1;
@@ -1565,7 +1567,7 @@ static int imb_exr_split_channel_name(ExrChannel *echan, char *layname, char *pa
/* all preceding tokens combined as layer name */
if (end > name) {
BLI_strncpy(layname, name, int(end - name) + 1);
BLI_strncpy(layname, name, std::min(layname_maxncpy, int(end - name) + 1));
}
else {
layname[0] = '\0';

View File

@@ -34,7 +34,7 @@ class AlembicExportTest : public testing::Test {
/* Fake a 25 FPS scene with a nonzero base (because that's sometimes forgotten) */
scene.r.frs_sec = 50;
scene.r.frs_sec_base = 2;
strcpy(scene.id.name, "SCTestScene");
STRNCPY(scene.id.name, "SCTestScene");
bmain = BKE_main_new();

View File

@@ -107,7 +107,7 @@ bNode *MaterialNode::add_node(int node_type, int locx, int locy, std::string lab
bNode *node = nodeAddStaticNode(mContext, ntree, node_type);
if (node) {
if (label.length() > 0) {
strcpy(node->label, label.c_str());
STRNCPY(node->label, label.c_str());
}
node->locx = locx;
node->locy = locy;

View File

@@ -1126,7 +1126,7 @@ static bNode *bc_add_node(
bNode *node = nodeAddStaticNode(C, ntree, node_type);
if (node) {
if (label.length() > 0) {
strcpy(node->label, label.c_str());
STRNCPY(node->label, label.c_str());
}
node->locx = locx;
node->locy = locy;

View File

@@ -78,7 +78,7 @@ bool GpencilImporterSVG::read()
MEM_freeN(layer_id);
layer_id = (shape->id_parent[0] == '\0') ? BLI_sprintfN("Layer_%03d", prefix) :
BLI_sprintfN("%s", shape->id_parent);
strcpy(prv_id, layer_id);
STRNCPY(prv_id, layer_id);
}
/* Check if the layer exist and create if needed. */

View File

@@ -4,6 +4,8 @@
#include "usd_reader_volume.h"
#include "BLI_string.h"
#include "BKE_object.h"
#include "BKE_volume.h"
@@ -77,7 +79,7 @@ void USDVolumeReader::read_object_data(Main *bmain, const double motionSampleTim
std::string filepath = fp.GetResolvedPath();
strcpy(volume->filepath, filepath.c_str());
STRNCPY(volume->filepath, filepath.c_str());
}
}

View File

@@ -412,7 +412,7 @@ static std::string get_in_memory_texture_filename(Image *ima)
char file_name[FILE_MAX];
/* Use the image name for the file name. */
strcpy(file_name, ima->id.name + 2);
STRNCPY(file_name, ima->id.name + 2);
BKE_image_path_ext_from_imformat_ensure(file_name, sizeof(file_name), &imageFormat);
@@ -432,7 +432,7 @@ static void export_in_memory_texture(Image *ima,
}
else {
/* Use the image name for the file name. */
strcpy(file_name, ima->id.name + 2);
STRNCPY(file_name, ima->id.name + 2);
}
ImBuf *imbuf = BKE_image_acquire_ibuf(ima, nullptr, nullptr);
@@ -674,7 +674,7 @@ static std::string get_tex_image_asset_filepath(bNode *node,
}
char rel_path[FILE_MAX];
strcpy(rel_path, path.c_str());
STRNCPY(rel_path, path.c_str());
BLI_path_rel(rel_path, stage_path.c_str());
if (!BLI_path_is_rel(rel_path)) {

View File

@@ -152,11 +152,11 @@ void register_node_tree_type_cmp()
bNodeTreeType *tt = ntreeType_Composite = MEM_cnew<bNodeTreeType>(__func__);
tt->type = NTREE_COMPOSIT;
strcpy(tt->idname, "CompositorNodeTree");
strcpy(tt->group_idname, "CompositorNodeGroup");
strcpy(tt->ui_name, N_("Compositor"));
STRNCPY(tt->idname, "CompositorNodeTree");
STRNCPY(tt->group_idname, "CompositorNodeGroup");
STRNCPY(tt->ui_name, N_("Compositor"));
tt->ui_icon = ICON_NODE_COMPOSITING;
strcpy(tt->ui_description, N_("Compositing nodes"));
STRNCPY(tt->ui_description, N_("Compositing nodes"));
tt->foreach_nodeclass = foreach_nodeclass;
tt->localize = localize;

View File

@@ -114,11 +114,11 @@ void register_node_tree_type_geo()
bNodeTreeType *tt = ntreeType_Geometry = static_cast<bNodeTreeType *>(
MEM_callocN(sizeof(bNodeTreeType), "geometry node tree type"));
tt->type = NTREE_GEOMETRY;
strcpy(tt->idname, "GeometryNodeTree");
strcpy(tt->group_idname, "GeometryNodeGroup");
strcpy(tt->ui_name, N_("Geometry Node Editor"));
STRNCPY(tt->idname, "GeometryNodeTree");
STRNCPY(tt->group_idname, "GeometryNodeGroup");
STRNCPY(tt->ui_name, N_("Geometry Node Editor"));
tt->ui_icon = ICON_GEOMETRY_NODES;
strcpy(tt->ui_description, N_("Geometry nodes"));
STRNCPY(tt->ui_description, N_("Geometry nodes"));
tt->rna_ext.srna = &RNA_GeometryNodeTree;
tt->update = geometry_node_tree_update;
tt->get_from_context = geometry_node_tree_get_from_context;

View File

@@ -29,9 +29,9 @@ static void register_undefined_types()
*/
blender::bke::NodeTreeTypeUndefined.type = NTREE_UNDEFINED;
strcpy(blender::bke::NodeTreeTypeUndefined.idname, "NodeTreeUndefined");
strcpy(blender::bke::NodeTreeTypeUndefined.ui_name, N_("Undefined"));
strcpy(blender::bke::NodeTreeTypeUndefined.ui_description, N_("Undefined Node Tree Type"));
STRNCPY(blender::bke::NodeTreeTypeUndefined.idname, "NodeTreeUndefined");
STRNCPY(blender::bke::NodeTreeTypeUndefined.ui_name, N_("Undefined"));
STRNCPY(blender::bke::NodeTreeTypeUndefined.ui_description, N_("Undefined Node Tree Type"));
node_type_base_custom(&blender::bke::NodeTypeUndefined, "NodeUndefined", "Undefined", 0);
blender::bke::NodeTypeUndefined.poll = node_undefined_poll;

View File

@@ -164,11 +164,11 @@ void register_node_tree_type_sh()
bNodeTreeType *tt = ntreeType_Shader = MEM_cnew<bNodeTreeType>("shader node tree type");
tt->type = NTREE_SHADER;
strcpy(tt->idname, "ShaderNodeTree");
strcpy(tt->group_idname, "ShaderNodeGroup");
strcpy(tt->ui_name, N_("Shader Editor"));
STRNCPY(tt->idname, "ShaderNodeTree");
STRNCPY(tt->group_idname, "ShaderNodeGroup");
STRNCPY(tt->ui_name, N_("Shader Editor"));
tt->ui_icon = ICON_NODE_MATERIAL;
strcpy(tt->ui_description, N_("Shader nodes"));
STRNCPY(tt->ui_description, N_("Shader nodes"));
tt->foreach_nodeclass = foreach_nodeclass;
tt->localize = localize;

View File

@@ -134,11 +134,11 @@ void register_node_tree_type_tex()
bNodeTreeType *tt = ntreeType_Texture = MEM_cnew<bNodeTreeType>("texture node tree type");
tt->type = NTREE_TEXTURE;
strcpy(tt->idname, "TextureNodeTree");
strcpy(tt->group_idname, "TextureNodeGroup");
strcpy(tt->ui_name, N_("Texture Node Editor"));
STRNCPY(tt->idname, "TextureNodeTree");
STRNCPY(tt->group_idname, "TextureNodeGroup");
STRNCPY(tt->ui_name, N_("Texture Node Editor"));
tt->ui_icon = ICON_NODE_TEXTURE; /* Defined in `drawnode.c`. */
strcpy(tt->ui_description, N_("Texture nodes"));
STRNCPY(tt->ui_description, N_("Texture nodes"));
tt->foreach_nodeclass = foreach_nodeclass;
tt->update = update;

View File

@@ -120,7 +120,7 @@ static void init(bNodeTree * /*ntree*/, bNode *node)
TexNodeOutput *tno = MEM_cnew<TexNodeOutput>("TEX_output");
node->storage = tno;
strcpy(tno->name, "Default");
STRNCPY(tno->name, "Default");
unique_name(node);
assign_index(node);
}

View File

@@ -13,6 +13,7 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_string.h"
#include "GHOST_C-api.h"
@@ -33,9 +34,7 @@
static wmXrActionSet *action_set_create(const char *action_set_name)
{
wmXrActionSet *action_set = MEM_callocN(sizeof(*action_set), __func__);
action_set->name = MEM_mallocN(strlen(action_set_name) + 1, "XrActionSet_Name");
strcpy(action_set->name, action_set_name);
action_set->name = BLI_strdup(action_set_name);
return action_set;
}
@@ -70,8 +69,7 @@ static wmXrAction *action_create(const char *action_name,
eXrHapticFlag haptic_flag)
{
wmXrAction *action = MEM_callocN(sizeof(*action), __func__);
action->name = MEM_mallocN(strlen(action_name) + 1, "XrAction_Name");
strcpy(action->name, action_name);
action->name = BLI_strdup(action_name);
action->type = type;
const uint count = (uint)BLI_listbase_count(user_paths);
@@ -81,9 +79,7 @@ static wmXrAction *action_create(const char *action_name,
action->subaction_paths = MEM_mallocN(sizeof(*action->subaction_paths) * count,
"XrAction_SubactionPaths");
LISTBASE_FOREACH_INDEX (XrUserPath *, user_path, user_paths, subaction_idx) {
action->subaction_paths[subaction_idx] = MEM_mallocN(strlen(user_path->path) + 1,
"XrAction_SubactionPath");
strcpy(action->subaction_paths[subaction_idx], user_path->path);
action->subaction_paths[subaction_idx] = BLI_strdup(user_path->path);
}
size_t size;
@@ -122,8 +118,7 @@ static wmXrAction *action_create(const char *action_name,
if (haptic_name) {
BLI_assert(is_button_action);
action->haptic_name = MEM_mallocN(strlen(haptic_name) + 1, "XrAction_HapticName");
strcpy(action->haptic_name, haptic_name);
action->haptic_name = BLI_strdup(haptic_name);
action->haptic_duration = *haptic_duration;
action->haptic_frequency = *haptic_frequency;
action->haptic_amplitude = *haptic_amplitude;
@@ -404,7 +399,7 @@ bool WM_xr_active_action_set_set(wmXrData *xr, const char *action_set_name, bool
if (delayed) {
/* Save name to activate action set later, before next actions sync
* (see #wm_xr_session_actions_update()). */
strcpy(xr->runtime->session_state.active_action_set_next, action_set_name);
STRNCPY(xr->runtime->session_state.active_action_set_next, action_set_name);
return true;
}

View File

@@ -16,6 +16,7 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_string.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
@@ -1039,11 +1040,11 @@ static wmXrActionData *wm_xr_session_event_create(const char *action_set_name,
bool bimanual)
{
wmXrActionData *data = MEM_callocN(sizeof(wmXrActionData), __func__);
strcpy(data->action_set, action_set_name);
strcpy(data->action, action->name);
strcpy(data->user_path, action->subaction_paths[subaction_idx]);
STRNCPY(data->action_set, action_set_name);
STRNCPY(data->action, action->name);
STRNCPY(data->user_path, action->subaction_paths[subaction_idx]);
if (bimanual) {
strcpy(data->user_path_other, action->subaction_paths[subaction_idx_other]);
STRNCPY(data->user_path_other, action->subaction_paths[subaction_idx_other]);
}
data->type = action->type;
@@ -1266,7 +1267,7 @@ void wm_xr_session_controller_data_populate(const wmXrAction *grip_action,
wmXrController *controller = MEM_callocN(sizeof(*controller), __func__);
BLI_assert(STREQ(grip_action->subaction_paths[i], aim_action->subaction_paths[i]));
strcpy(controller->subaction_path, grip_action->subaction_paths[i]);
STRNCPY(controller->subaction_path, grip_action->subaction_paths[i]);
BLI_addtail(controllers, controller);
}