Merge pull request #8688 from howard0su/cleanup_strncpy

Remove warning of -Wstringop-truncation
This commit is contained in:
Léo Lam 2020-04-28 14:28:30 +02:00 committed by GitHub
commit 93abbc66aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -50,7 +50,7 @@ bool CEXIETHERNET::Activate()
const int MAX_INTERFACES = 32;
for (int i = 0; i < MAX_INTERFACES; ++i)
{
strncpy(ifr.ifr_name, StringFromFormat("Dolphin%d", i).c_str(), IFNAMSIZ);
strncpy(ifr.ifr_name, StringFromFormat("Dolphin%d", i).c_str(), IFNAMSIZ - 1);
int err;
if ((err = ioctl(fd, TUNSETIFF, (void*)&ifr)) < 0)

View File

@ -420,9 +420,9 @@ static CertECC MakeBlankEccCert(const std::string& issuer, const std::string& na
{
CertECC cert{};
cert.signature.type = SignatureType(Common::swap32(u32(SignatureType::ECC)));
std::strncpy(cert.signature.issuer, issuer.c_str(), 0x40);
issuer.copy(cert.signature.issuer, sizeof(cert.signature.issuer) - 1);
cert.header.public_key_type = PublicKeyType(Common::swap32(u32(PublicKeyType::ECC)));
std::strncpy(cert.header.name, name.c_str(), 0x40);
name.copy(cert.header.name, sizeof(cert.header.name) - 1);
cert.header.id = Common::swap32(key_id);
cert.public_key = Common::ec::PrivToPub(private_key);
return cert;

View File

@ -341,8 +341,8 @@ static void CompressAndDumpState(CompressAndDumpState_args save_args)
}
// Setting up the header
StateHeader header;
strncpy(header.gameID, SConfig::GetInstance().GetGameID().c_str(), 6);
StateHeader header{};
SConfig::GetInstance().GetGameID().copy(header.gameID, std::size(header.gameID));
header.size = g_use_compression ? (u32)buffer_size : 0;
header.time = Common::Timer::GetDoubleTime();