Remove strcpy. (#5802)

* Remove strcpy.

* Sonarcube: Add more strcpy replacements

* BlenderLoader: Replace strncpy by memcpy
This commit is contained in:
Kim Kulling
2024-11-18 16:54:58 +01:00
committed by GitHub
parent f5fb8ff842
commit 41cc2f66a4
8 changed files with 20 additions and 29 deletions

View File

@@ -1,11 +1,9 @@
/*
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2024, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
@@ -495,8 +493,9 @@ void BlenderImporter::BuildDefaultMaterial(Blender::ConversionData &conv_data) {
if (index == static_cast<unsigned int>(-1)) {
// Setup a default material.
std::shared_ptr<Material> p(new Material());
ai_assert(::strlen(AI_DEFAULT_MATERIAL_NAME) < sizeof(p->id.name) - 2);
strcpy(p->id.name + 2, AI_DEFAULT_MATERIAL_NAME);
const size_t len = ::strlen(AI_DEFAULT_MATERIAL_NAME);
ai_assert(len < sizeof(p->id.name) - 2);
memcpy(p->id.name + 2, AI_DEFAULT_MATERIAL_NAME, len);
// Note: MSVC11 does not zero-initialize Material here, although it should.
// Thus all relevant fields should be explicitly initialized. We cannot add