diff --git a/code/AssetLib/Collada/ColladaParser.cpp b/code/AssetLib/Collada/ColladaParser.cpp index fd2662ddb..cc2c791fe 100644 --- a/code/AssetLib/Collada/ColladaParser.cpp +++ b/code/AssetLib/Collada/ColladaParser.cpp @@ -67,7 +67,7 @@ static void ReportWarning(const char *msg, ...) { va_start(args, msg); char szBuffer[3000]; - const int iLen = vsprintf(szBuffer, msg, args); + const int iLen = vsnprintf(szBuffer, 3000, msg, args); ai_assert(iLen > 0); va_end(args); diff --git a/code/AssetLib/FBX/FBXExporter.cpp b/code/AssetLib/FBX/FBXExporter.cpp index 563ac68f0..8eaa4bcc4 100644 --- a/code/AssetLib/FBX/FBXExporter.cpp +++ b/code/AssetLib/FBX/FBXExporter.cpp @@ -1228,7 +1228,7 @@ void FBXExporter::WriteObjects () "Version", int32_t(101), outstream, binary, indent ); char layerName[8]; - sprintf(layerName, "COLOR_%d", colorChannelIndex); + snprintf(layerName, 8, "COLOR_%d", colorChannelIndex); FBX::Node::WritePropertyNode( "Name", (const char*)layerName, outstream, binary, indent ); diff --git a/code/AssetLib/MD5/MD5Parser.cpp b/code/AssetLib/MD5/MD5Parser.cpp index 462da9cf3..f6b19462a 100644 --- a/code/AssetLib/MD5/MD5Parser.cpp +++ b/code/AssetLib/MD5/MD5Parser.cpp @@ -99,7 +99,7 @@ MD5Parser::MD5Parser(char *_buffer, unsigned int _fileSize) : buffer(_buffer), b // Report warning to the log stream /*static*/ void MD5Parser::ReportWarning(const char *warn, unsigned int line) { char szBuffer[1024]; - ::sprintf(szBuffer, "[MD5] Line %u: %s", line, warn); + ::snprintf(szBuffer, 1024, "[MD5] Line %u: %s", line, warn); ASSIMP_LOG_WARN(szBuffer); } diff --git a/code/AssetLib/MDL/MDLLoader.cpp b/code/AssetLib/MDL/MDLLoader.cpp index b2bd2d2f1..6f0cc7a1c 100644 --- a/code/AssetLib/MDL/MDLLoader.cpp +++ b/code/AssetLib/MDL/MDLLoader.cpp @@ -298,7 +298,7 @@ void MDLImporter::SizeCheck(const void *szPos, const char *szFile, unsigned int } char szBuffer[1024]; - ::sprintf(szBuffer, "Invalid MDL file. The file is too small " + ::snprintf(szBuffer, 1024, "Invalid MDL file. The file is too small " "or contains invalid data (File: %s Line: %u)", szFilePtr, iLine); diff --git a/code/PostProcessing/ValidateDataStructure.cpp b/code/PostProcessing/ValidateDataStructure.cpp index 54889f34b..6d3611cf8 100644 --- a/code/PostProcessing/ValidateDataStructure.cpp +++ b/code/PostProcessing/ValidateDataStructure.cpp @@ -80,7 +80,7 @@ AI_WONT_RETURN void ValidateDSProcess::ReportError(const char *msg, ...) { va_start(args, msg); char szBuffer[3000]; - const int iLen = vsprintf(szBuffer, msg, args); + const int iLen = vsnprintf(szBuffer, 3000, msg, args); ai_assert(iLen > 0); va_end(args); @@ -95,7 +95,7 @@ void ValidateDSProcess::ReportWarning(const char *msg, ...) { va_start(args, msg); char szBuffer[3000]; - const int iLen = vsprintf(szBuffer, msg, args); + const int iLen = vsnprintf(szBuffer, 3000, msg, args); ai_assert(iLen > 0); va_end(args); diff --git a/contrib/openddlparser/code/OpenDDLExport.cpp b/contrib/openddlparser/code/OpenDDLExport.cpp index d235b553b..10f9ad9c9 100644 --- a/contrib/openddlparser/code/OpenDDLExport.cpp +++ b/contrib/openddlparser/code/OpenDDLExport.cpp @@ -224,7 +224,7 @@ bool OpenDDLExport::writeValueType(Value::ValueType type, size_t numItems, std:: statement += "["; char buffer[256]; ::memset(buffer, '\0', 256 * sizeof(char)); - sprintf(buffer, "%d", static_cast(numItems)); + snprintf(buffer, 256, "%d", static_cast(numItems)); statement += buffer; statement += "]"; } @@ -255,7 +255,7 @@ bool OpenDDLExport::writeValue(Value *val, std::string &statement) { std::stringstream stream; char buffer[256]; ::memset(buffer, '\0', 256 * sizeof(char)); - sprintf(buffer, "%d", val->getInt16()); + snprintf(buffer, 256, "%d", val->getInt16()); statement += buffer; } break; case Value::ValueType::ddl_int32: { @@ -263,7 +263,7 @@ bool OpenDDLExport::writeValue(Value *val, std::string &statement) { char buffer[256]; ::memset(buffer, '\0', 256 * sizeof(char)); const int i = static_cast(val->getInt32()); - sprintf(buffer, "%d", i); + snprintf(buffer, 256, "%d", i); statement += buffer; } break; case Value::ValueType::ddl_int64: {