sprintf: replace more sprintf by snprintf.
parent
c9d00beab8
commit
c3d4be1dce
|
@ -143,7 +143,7 @@ void Parser::LogWarning(const char* szWarn)
|
|||
|
||||
char szTemp[1024];
|
||||
#if _MSC_VER >= 1400
|
||||
sprintf_s(szTemp,"Line %u: %s",iLineNumber,szWarn);
|
||||
sprintf_s(szTemp, "Line %u: %s",iLineNumber,szWarn);
|
||||
#else
|
||||
snprintf(szTemp,1024,"Line %u: %s",iLineNumber,szWarn);
|
||||
#endif
|
||||
|
@ -825,7 +825,7 @@ bool Parser::ParseString(std::string& out,const char* szName)
|
|||
if (!SkipSpaces(&filePtr))
|
||||
{
|
||||
|
||||
sprintf(szBuffer,"Unable to parse %s block: Unexpected EOL",szName);
|
||||
snprintf(szBuffer, 1023, "Unable to parse %s block: Unexpected EOL",szName);
|
||||
LogWarning(szBuffer);
|
||||
return false;
|
||||
}
|
||||
|
@ -833,7 +833,7 @@ bool Parser::ParseString(std::string& out,const char* szName)
|
|||
if ('\"' != *filePtr)
|
||||
{
|
||||
|
||||
sprintf(szBuffer,"Unable to parse %s block: Strings are expected "
|
||||
snprintf(szBuffer, 1023, "Unable to parse %s block: Strings are expected "
|
||||
"to be enclosed in double quotation marks",szName);
|
||||
LogWarning(szBuffer);
|
||||
return false;
|
||||
|
@ -845,7 +845,7 @@ bool Parser::ParseString(std::string& out,const char* szName)
|
|||
if ('\"' == *sz)break;
|
||||
else if ('\0' == *sz)
|
||||
{
|
||||
sprintf(szBuffer,"Unable to parse %s block: Strings are expected to "
|
||||
snprintf(szBuffer, 1024, "Unable to parse %s block: Strings are expected to "
|
||||
"be enclosed in double quotation marks but EOF was reached before "
|
||||
"a closing quotation mark was encountered",szName);
|
||||
LogWarning(szBuffer);
|
||||
|
|
|
@ -133,7 +133,7 @@ struct Bone
|
|||
|
||||
// Generate a default name for the bone
|
||||
char szTemp[128];
|
||||
::sprintf(szTemp,"UNNAMED_%i",iCnt++);
|
||||
::snprintf(szTemp, 128, "UNNAMED_%i",iCnt++);
|
||||
mName = szTemp;
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ struct BaseNode
|
|||
// generate a default name for the node
|
||||
static int iCnt = 0;
|
||||
char szTemp[128]; // should be sufficiently large
|
||||
::sprintf(szTemp,"UNNAMED_%i",iCnt++);
|
||||
::snprintf(szTemp, 128, "UNNAMED_%i",iCnt++);
|
||||
mName = szTemp;
|
||||
|
||||
// Set mTargetPosition to qnan
|
||||
|
|
|
@ -571,7 +571,7 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
|
|||
|
||||
if (!DefaultLogger::isNullLogger()) {
|
||||
char dmp[128];
|
||||
sprintf(dmp,"B3D file format version: %i",version);
|
||||
snprintf(dmp, 128, "B3D file format version: %i",version);
|
||||
DefaultLogger::get()->info(dmp);
|
||||
}
|
||||
|
||||
|
|
|
@ -496,7 +496,7 @@ void BlenderImporter::AddSentinelTexture(aiMaterial* out, const Material* mat, c
|
|||
(void)mat; (void)tex; (void)conv_data;
|
||||
|
||||
aiString name;
|
||||
name.length = sprintf(name.data, "Procedural,num=%i,type=%s",conv_data.sentinel_cnt++,
|
||||
name.length = snprintf(name.data, MAXLEN, "Procedural,num=%i,type=%s",conv_data.sentinel_cnt++,
|
||||
GetTextureTypeDisplayString(tex->tex->type)
|
||||
);
|
||||
out->AddProperty(&name,AI_MATKEY_TEXTURE_DIFFUSE(
|
||||
|
|
|
@ -196,7 +196,7 @@ void IRRImporter::BuildSkybox(std::vector<aiMesh*>& meshes, std::vector<aiMateri
|
|||
aiMaterial* out = ( aiMaterial* ) (*(materials.end()-(6-i)));
|
||||
|
||||
aiString s;
|
||||
s.length = ::sprintf( s.data, "SkyboxSide_%u",i );
|
||||
s.length = ::snprintf( s.data, MAXLEN, "SkyboxSide_%u",i );
|
||||
out->AddProperty(&s,AI_MATKEY_NAME);
|
||||
|
||||
int shading = aiShadingMode_NoShading;
|
||||
|
@ -347,7 +347,7 @@ void IRRImporter::ComputeAnimations(Node* root, aiNode* real, std::vector<aiNode
|
|||
if (cur != total-1) {
|
||||
// Build a new name - a prefix instead of a suffix because it is
|
||||
// easier to check against
|
||||
anim->mNodeName.length = ::sprintf(anim->mNodeName.data,
|
||||
anim->mNodeName.length = ::snprintf(anim->mNodeName.data, MAXLEN,
|
||||
"$INST_DUMMY_%i_%s",total-1,
|
||||
(root->name.length() ? root->name.c_str() : ""));
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ private:
|
|||
// Generate a default name for the node
|
||||
char buffer[128];
|
||||
static int cnt;
|
||||
::sprintf(buffer,"IrrNode_%i",cnt++);
|
||||
::snprintf(buffer, 128, "IrrNode_%i",cnt++);
|
||||
name = std::string(buffer);
|
||||
|
||||
// reserve space for up to 5 materials
|
||||
|
|
|
@ -505,7 +505,7 @@ const aiScene* Importer::ReadFileFromMemory( const void* pBuffer,
|
|||
// read the file and recover the previous IOSystem
|
||||
static const size_t BufferSize(Importer::MaxLenHint + 28);
|
||||
char fbuff[ BufferSize ];
|
||||
sprintf(fbuff,"%s.%s",AI_MEMORYIO_MAGIC_FILENAME,pHint);
|
||||
snprintf(fbuff, BufferSize, "%s.%s",AI_MEMORYIO_MAGIC_FILENAME,pHint);
|
||||
|
||||
ReadFile(fbuff,pFlags);
|
||||
SetIOHandler(io);
|
||||
|
|
|
@ -310,7 +310,7 @@ void SceneCombiner::MergeScenes(aiScene** _dest, aiScene* master,
|
|||
// continue;
|
||||
//}
|
||||
|
||||
src[i].idlen = ::sprintf(src[i].id,"$%.6X$_",i);
|
||||
src[i].idlen = ::snprintf(src[i].id, 32, "$%.6X$_",i);
|
||||
|
||||
if (flags & AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY) {
|
||||
|
||||
|
|
|
@ -344,7 +344,7 @@ void CatmullClarkSubdivider::InternSubdivide (
|
|||
// faces in the mesh. They occur at outer model boundaries in non-closed
|
||||
// shapes.
|
||||
char tmp[512];
|
||||
sprintf(tmp,"Catmull-Clark Subdivider: got %u bad edges touching only one face (totally %u edges). ",
|
||||
snprintf(tmp, 512, "Catmull-Clark Subdivider: got %u bad edges touching only one face (totally %u edges). ",
|
||||
bad_cnt,static_cast<unsigned int>(edges.size()));
|
||||
|
||||
DefaultLogger::get()->debug(tmp);
|
||||
|
|
|
@ -840,7 +840,7 @@ inline void AssetMetadata::Read(Document& doc)
|
|||
|
||||
if (version != 1) {
|
||||
char msg[128];
|
||||
sprintf(msg, "Unsupported glTF version: %d", version);
|
||||
::snprintf(msg, 128, "Unsupported glTF version: %d", version);
|
||||
throw DeadlyImportError(msg);
|
||||
}
|
||||
}
|
||||
|
@ -923,7 +923,7 @@ inline void Asset::Load(const std::string& pFile, bool isBinary)
|
|||
|
||||
if (doc.HasParseError()) {
|
||||
char buffer[32];
|
||||
sprintf(buffer, "%d", static_cast<int>(doc.GetErrorOffset()));
|
||||
::snprintf(buffer, 32, "%d", static_cast<int>(doc.GetErrorOffset()));
|
||||
throw DeadlyImportError(std::string("JSON parse error, offset ") + buffer + ": "
|
||||
+ GetParseError_En(doc.GetParseError()));
|
||||
}
|
||||
|
@ -1027,9 +1027,9 @@ inline std::string Asset::FindUniqueID(const std::string& str, const char* suffi
|
|||
if (it == mUsedIds.end()) break;
|
||||
|
||||
char buffer[256];
|
||||
int offset = sprintf(buffer, "%s_", id.c_str());
|
||||
int offset = snprintf(buffer, 256, "%s_", id.c_str());
|
||||
for (int i = 0; it != mUsedIds.end(); ++i) {
|
||||
sprintf(buffer + offset, "%d", i);
|
||||
::snprintf(buffer + offset, 256, "%d", i);
|
||||
|
||||
id = buffer;
|
||||
it = mUsedIds.find(id);
|
||||
|
|
|
@ -190,7 +190,7 @@ namespace glTF {
|
|||
else {
|
||||
for (size_t i = 0; i < lst.size(); ++i) {
|
||||
char buffer[32];
|
||||
sprintf(buffer, "%s_%d", semantic, int(i));
|
||||
snprintf(buffer, 32, "%s_%d", semantic, int(i));
|
||||
attrs.AddMember(Value(buffer, w.mAl).Move(), Value(lst[i]->id, w.mAl).Move(), w.mAl);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -351,7 +351,7 @@ void glTFExporter::ExportMetadata()
|
|||
asset.version = 1;
|
||||
|
||||
char buffer[256];
|
||||
sprintf(buffer, "Open Asset Import Library (assimp v%d.%d.%d)",
|
||||
snprintf(buffer, 256, "Open Asset Import Library (assimp v%d.%d.%d)",
|
||||
aiGetVersionMajor(), aiGetVersionMinor(), aiGetVersionRevision());
|
||||
|
||||
asset.generator = buffer;
|
||||
|
|
Loading…
Reference in New Issue