1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-17 20:13:07 +01:00

fix several safe_strncpy calls

This commit is contained in:
IntelOrca
2015-11-02 21:23:01 +00:00
parent 2c58e1d894
commit a0909a242d
2 changed files with 5 additions and 14 deletions

View File

@@ -317,27 +317,19 @@ void scenario_begin()
{
// Get filename
utf8 filename[MAX_PATH];
int len = strnlen(_scenarioFileName, MAX_PATH);
safe_strncpy(filename, _scenarioFileName, len);
if (len == MAX_PATH)
{
filename[MAX_PATH - 1] = '\0';
log_warning("truncated string %s", filename);
}
safe_strncpy(filename, _scenarioFileName, sizeof(filename));
path_remove_extension(filename);
rct_string_id localisedStringIds[3];
if (language_get_localised_scenario_strings(filename, localisedStringIds)) {
if (localisedStringIds[0] != (rct_string_id)STR_NONE) {
safe_strncpy((char*)RCT2_ADDRESS_SCENARIO_NAME, language_get_string(localisedStringIds[0]), 31);
((char*)RCT2_ADDRESS_SCENARIO_NAME)[31] = '\0';
safe_strncpy((char*)RCT2_ADDRESS_SCENARIO_NAME, language_get_string(localisedStringIds[0]), 32);
}
if (localisedStringIds[1] != (rct_string_id)STR_NONE) {
park_set_name(language_get_string(localisedStringIds[1]));
}
if (localisedStringIds[2] != (rct_string_id)STR_NONE) {
safe_strncpy((char*)RCT2_ADDRESS_SCENARIO_DETAILS, language_get_string(localisedStringIds[2]), 255);
((char*)RCT2_ADDRESS_SCENARIO_DETAILS)[255] = '\0';
safe_strncpy((char*)RCT2_ADDRESS_SCENARIO_DETAILS, language_get_string(localisedStringIds[2]), 256);
}
} else {
rct_stex_entry* stex = g_stexEntries[0];

View File

@@ -642,15 +642,14 @@ static void window_loadsave_populate_list(int includeNewItem, bool browsable, co
if (!topLevel){
listItem = &_listItems[_listItemsCount];
safe_strncpy(listItem->name, language_get_string(2718), sizeof(listItem->name));
memset(listItem->path, '\0', MAX_PATH);
safe_strncpy(listItem->path, directory, lastSlash + 1);
safe_strncpy(listItem->path, directory, sizeof(listItem->path));
listItem->type = TYPE_UP;
_listItemsCount++;
} else if (platform_get_drives() != 0 && directory[0] != '\0'){
includeNewItem = false;
listItem = &_listItems[_listItemsCount];
safe_strncpy(listItem->name, language_get_string(2718), sizeof(listItem->name));
memset(listItem->path, '\0', MAX_PATH);
memset(listItem->path, '\0', sizeof(listItem->path));
listItem->type = TYPE_UP;
_listItemsCount++;
}