Merge pull request #1283 from EQEmu/cleanup/Wformat-overflow

[Cleanup] Make code -Wformat-overflow safe
This commit is contained in:
Alex
2021-03-05 19:23:48 -08:00
committed by GitHub
6 changed files with 23 additions and 82 deletions
+10 -3
View File
@@ -2254,8 +2254,12 @@ void NPC::PetOnSpawn(NewSpawn_Struct* ns)
if (RuleB(Pets, UnTargetableSwarmPet))
{
ns->spawn.bodytype = 11;
if(!IsCharmed() && swarmOwner->IsClient())
sprintf(ns->spawn.lastName, "%s's Pet", swarmOwner->GetName());
if(!IsCharmed() && swarmOwner->IsClient()) {
std::string tmp_lastname = swarmOwner->GetName();
tmp_lastname += "'s Pet";
if (tmp_lastname.size() < sizeof(ns->spawn.lastName))
strn0cpy(ns->spawn.lastName, tmp_lastname.c_str(), sizeof(ns->spawn.lastName));
}
}
}
else if(GetOwnerID())
@@ -2267,7 +2271,10 @@ void NPC::PetOnSpawn(NewSpawn_Struct* ns)
if(client)
{
SetPetOwnerClient(true);
sprintf(ns->spawn.lastName, "%s's Pet", client->GetName());
std::string tmp_lastname = swarmOwner->GetName();
tmp_lastname += "'s Pet";
if (tmp_lastname.size() < sizeof(ns->spawn.lastName))
strn0cpy(ns->spawn.lastName, tmp_lastname.c_str(), sizeof(ns->spawn.lastName));
}
}
}