Merge pull request #1239 from suve/use-sizeof-in-ModelOutput-WriteOldModel

Tweak strncpy() usage in ModelOutput::WriteOldModel
1008-fix
tomangelo 2019-02-07 01:11:55 +01:00 committed by GitHub
commit b50a71bde4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -328,7 +328,10 @@ void ModelOutput::WriteOldModel(const CModel& model, std::ostream &stream)
t.material.ambient = triangle.ambient;
t.material.diffuse = triangle.diffuse;
t.material.specular = triangle.specular;
strncpy(t.texName, triangle.tex1Name.c_str(), 20);
strncpy(t.texName, triangle.tex1Name.c_str(), sizeof(t.texName)-1);
t.texName[sizeof(t.texName)-1] = '\0';
t.min = 0.0f;
t.max = 1000000.0f;
t.state = ConvertToOldState(triangle);