Fix -Wstringop-truncation issues

This commit is contained in:
Luke Street 2021-04-05 13:22:56 -04:00
parent b585305009
commit 106bb02fbf
2 changed files with 5 additions and 3 deletions

View File

@ -329,10 +329,12 @@ ECardResult Card::renameFile(const char* oldName, const char* newName) {
if (File* replF = dir.getFile(m_game, m_maker, newName)) {
BlockAllocationTable bat = m_bats[m_currentBat];
_deleteFile(*replF, bat);
std::strncpy(f->m_filename, newName, 32);
std::memset(f->m_filename, 0, std::size(f->m_filename));
std::strncpy(f->m_filename, newName, std::size(m_filename) - 1);
_updateDirAndBat(dir, bat);
} else {
std::strncpy(f->m_filename, newName, 32);
std::memset(f->m_filename, 0, std::size(f->m_filename));
std::strncpy(f->m_filename, newName, std::size(m_filename) - 1);
_updateDirAndBat(dir, m_bats[m_currentBat]);
}
return ECardResult::READY;

View File

@ -13,7 +13,7 @@ File::File(const RawData& rawData) : raw{rawData} {}
File::File(const char* filename) {
raw.fill(0);
std::memset(m_filename, 0, std::size(m_filename));
std::strncpy(m_filename, filename, std::size(m_filename));
std::strncpy(m_filename, filename, std::size(m_filename) - 1);
}
void File::swapEndian() {
m_modifiedTime = SBig(m_modifiedTime);