Fixed a crash bug in FullItemDescInBarter

* when weapon/ammo has no description, it'd trigger UB from strncpy_s.
This commit is contained in:
NovaRain
2022-12-17 10:35:39 +08:00
parent 05f2fb4001
commit 52e796815a
2 changed files with 5 additions and 2 deletions
+3
View File
@@ -1693,6 +1693,9 @@ static bool showItemDescription = false;
static void __stdcall AppendText(const char* text, const char* desc) {
if (showItemDescription && currDescLen == 0) {
if (desc == nullptr) {
desc = fo::util::MessageSearch(&fo::var::proto_main_msg_file, 493);
}
strncpy_s(messageBuffer, desc, 161);
int len = strlen(messageBuffer);
if (len > 160) {
+2 -2
View File
@@ -49,7 +49,7 @@ std::vector<std::string> Translate::GetList(const char* section, const char* set
static void MakeLangTranslationPath(const char* config) {
char patches[65], language[32];
char fileConfig[65] = ".\\";
char fileConfig[67] = ".\\";
std::strcpy(&fileConfig[2], config);
IniReader::GetString("system", "language", "english", language, 32, fileConfig);
@@ -74,7 +74,7 @@ static void InitMessagesTranslate() {
combatBlockedMessage = Translate::Get("sfall", "BlockedCombat", "You cannot enter combat at this time.");
combatSaveFailureMsg = Translate::Get("sfall", "SaveInCombat", "Cannot save at this time.");
saveSfallDataFailMsg = Translate::Get("sfall", "SaveSfallDataFail", "ERROR saving extended savegame information! "
"Check if other programs interfere with savegame files/folders and try again!");
"Check if other programs interfere with savegame files/folders and try again.");
}
void Translate::init(const char* config) {