Replace more strlcat calls with strlcpy

pull/15396/head
libretroadmin 2023-06-18 19:24:58 +02:00
parent c723710c90
commit edecf0cb2d
14 changed files with 229 additions and 184 deletions

View File

@ -2103,7 +2103,8 @@ static void win32_localize_menu(HMENU menu)
buf_size);
new_label_text[_len ] = '\t';
new_label_text[_len+1] = '\0';
strlcat(new_label_text, meta_key_name, buf_size);
_len += 1;
strlcpy(new_label_text + _len, meta_key_name, buf_size - _len);
/* Make first character of shortcut name uppercase */
new_label_text[len1 + 1] = toupper(new_label_text[len1 + 1]);
}

View File

@ -1346,9 +1346,9 @@ struct string_list* cdrom_get_available_drives(void)
if (string_starts_with_size(dir_list->elems[i].data, "/dev/sg",
STRLEN_CONST("/dev/sg")))
{
char drive_string[33];
libretro_vfs_implementation_file *stream;
char drive_model[32] = {0};
char drive_string[33] = {0};
union string_list_elem_attr attr = {0};
int dev_index = 0;
RFILE *file = filestream_open(
@ -1380,9 +1380,9 @@ struct string_list* cdrom_get_available_drives(void)
attr.i = dev_index;
if (!string_is_empty(drive_model))
strlcat(drive_string, drive_model, sizeof(drive_string));
strlcpy(drive_string, drive_model, sizeof(drive_string));
else
strlcat(drive_string, "Unknown Drive", sizeof(drive_string));
strlcpy(drive_string, "Unknown Drive", sizeof(drive_string));
string_list_append(list, drive_string, attr);
}
@ -1462,10 +1462,10 @@ struct string_list* cdrom_get_available_drives(void)
continue;
{
char drive_string[33];
libretro_vfs_implementation_file *stream;
bool is_cdrom = false;
char drive_model[32] = {0};
char drive_string[33] = {0};
union string_list_elem_attr attr = {0};
RFILE *file = filestream_open(cdrom_path, RETRO_VFS_FILE_ACCESS_READ, 0);
if (!file)
@ -1481,9 +1481,9 @@ struct string_list* cdrom_get_available_drives(void)
attr.i = path[0];
if (!string_is_empty(drive_model))
strlcat(drive_string, drive_model, sizeof(drive_string));
strlcpy(drive_string, drive_model, sizeof(drive_string));
else
strlcat(drive_string, "Unknown Drive", sizeof(drive_string));
strlcpy(drive_string, "Unknown Drive", sizeof(drive_string));
string_list_append(list, drive_string, attr);
}

View File

@ -366,8 +366,8 @@ static void config_file_get_realpath(char *s, size_t len,
const char *home = getenv("HOME");
if (home)
{
strlcpy(s, home, len);
strlcat(s, path + 1, len);
size_t _len = strlcpy(s, home, len);
strlcpy(s + _len, path + 1, len - _len);
}
else
strlcpy(s, path + 1, len);

View File

@ -419,7 +419,8 @@ void net_http_urlencode_full(char *dest,
buf_pos = strlcpy(dest, url_domain, size);
dest[buf_pos] = '/';
dest[buf_pos+1] = '\0';
strlcat(dest, tmp, size);
buf_pos += 1;
strlcpy(dest + buf_pos, tmp, size - buf_pos);
free (tmp);
}

View File

@ -421,19 +421,15 @@ static int general_push(menu_displaylist_info_t *info,
{
/* Need to use the scratch buffer here */
char tmp_str[PATH_MAX_LENGTH];
char tmp_str2[PATH_MAX_LENGTH];
fill_pathname_join_special(tmp_str, menu->scratch2_buf,
menu->scratch_buf, sizeof(tmp_str));
fill_pathname_join_special(tmp_str2, menu->scratch2_buf,
menu->scratch_buf, sizeof(tmp_str2));
if (!string_is_empty(info->path))
free(info->path);
info->path = strdup(tmp_str);
if (!string_is_empty(info->label))
free(info->label);
info->path = strdup(tmp_str);
info->label = strdup(tmp_str2);
info->label = strdup(tmp_str);
}
info->type_default = FILE_TYPE_PLAIN;

View File

@ -3856,6 +3856,7 @@ static int action_ok_path_manual_scan_directory(const char *path,
static int action_ok_core_deferred_set(const char *new_core_path,
const char *content_label, unsigned type, size_t idx, size_t entry_idx)
{
size_t _len;
char msg[PATH_MAX_LENGTH];
char resolved_core_path[PATH_MAX_LENGTH];
struct menu_state *menu_st = menu_state_get_ptr();
@ -3891,8 +3892,8 @@ static int action_ok_core_deferred_set(const char *new_core_path,
&entry);
/* Provide visual feedback */
strlcpy(msg, msg_hash_to_str(MSG_SET_CORE_ASSOCIATION), sizeof(msg));
strlcat(msg, core_display_name, sizeof(msg));
_len = strlcpy(msg, msg_hash_to_str(MSG_SET_CORE_ASSOCIATION), sizeof(msg));
strlcpy(msg + _len, core_display_name, sizeof(msg) - _len);
runloop_msg_queue_push(msg, 1, 100, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
menu_entries_pop_stack(&selection, 0, 1);
@ -3947,18 +3948,18 @@ static int action_ok_set_switch_cpu_profile(const char *path,
#endif
#ifdef HAVE_LAKKA_SWITCH
static int action_ok_set_switch_gpu_profile(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
size_t _len;
char command[PATH_MAX_LENGTH];
char *profile_name = SWITCH_GPU_PROFILES[entry_idx];
size_t _len = strlcpy(command, "gpu-profile set ", sizeof(command));
snprintf(command + _len, sizeof(command) - _len, "'%s'", profile_name);
system(command);
/* TODO/FIXME - localize */
strlcpy(command, "Current profile set to ", sizeof(command));
strlcat(command, profile_name, sizeof(command));
_len = strlcpy(command, "Current profile set to ", sizeof(command));
strlcpy(command + _len, profile_name, sizeof(command) - _len);
runloop_msg_queue_push(command, 1, 90, true, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
return -1;
@ -7664,12 +7665,11 @@ int action_ok_core_lock(const char *path,
if (!core_info_set_core_lock(core_path, lock))
{
size_t _len;
const char *core_name = NULL;
core_info_t *core_info = NULL;
char msg[PATH_MAX_LENGTH];
msg[0] = '\0';
/* Need to fetch core name for error message */
/* If core is found, use display name */
@ -7681,20 +7681,18 @@ int action_ok_core_lock(const char *path,
core_name = path_basename_nocompression(core_path);
/* Build error message */
strlcpy(
msg,
_len = strlcpy(msg,
msg_hash_to_str(lock ?
MSG_CORE_LOCK_FAILED : MSG_CORE_UNLOCK_FAILED),
sizeof(msg));
if (!string_is_empty(core_name))
strlcat(msg, core_name, sizeof(msg));
strlcpy(msg + _len, core_name, sizeof(msg) - _len);
/* Generate log + notification */
RARCH_ERR("%s\n", msg);
runloop_msg_queue_push(
msg,
runloop_msg_queue_push(msg,
1, 100, true,
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
@ -7728,12 +7726,11 @@ int action_ok_core_set_standalone_exempt(const char *path,
if (!core_info_set_core_standalone_exempt(core_path, exempt))
{
const char *core_name = NULL;
size_t _len;
const char *core_name = NULL;
core_info_t *core_info = NULL;
char msg[PATH_MAX_LENGTH];
msg[0] = '\0';
/* Need to fetch core name for error message */
/* If core is found, use display name */
@ -7745,15 +7742,14 @@ int action_ok_core_set_standalone_exempt(const char *path,
core_name = path_basename_nocompression(core_path);
/* Build error message */
strlcpy(
msg,
_len = strlcpy(msg,
msg_hash_to_str(exempt ?
MSG_CORE_SET_STANDALONE_EXEMPT_FAILED :
MSG_CORE_UNSET_STANDALONE_EXEMPT_FAILED),
sizeof(msg));
if (!string_is_empty(core_name))
strlcat(msg, core_name, sizeof(msg));
strlcpy(msg + _len, core_name, sizeof(msg) - _len);
/* Generate log + notification */
RARCH_ERR("%s\n", msg);
@ -7780,12 +7776,11 @@ static int action_ok_core_delete(const char *path,
/* Check whether core is locked */
if (core_info_get_core_lock(core_path, true))
{
size_t _len;
const char *core_name = NULL;
core_info_t *core_info = NULL;
char msg[PATH_MAX_LENGTH];
msg[0] = '\0';
/* Need to fetch core name for notification */
/* If core is found, use display name */
@ -7797,10 +7792,10 @@ static int action_ok_core_delete(const char *path,
core_name = path_basename_nocompression(core_path);
/* Build notification message */
strlcpy(msg, msg_hash_to_str(MSG_CORE_DELETE_DISABLED), sizeof(msg));
_len = strlcpy(msg, msg_hash_to_str(MSG_CORE_DELETE_DISABLED), sizeof(msg));
if (!string_is_empty(core_name))
strlcat(msg, core_name, sizeof(msg));
strlcpy(msg + _len, core_name, sizeof(msg) - _len);
runloop_msg_queue_push(
msg,
@ -7827,11 +7822,10 @@ static int action_ok_core_delete(const char *path,
* interface */
if (play_feature_delivery_enabled())
{
size_t _len;
const char *core_filename = path_basename_nocompression(core_path);
char backup_core_path[PATH_MAX_LENGTH];
backup_core_path[0] = '\0';
if (play_feature_delivery_core_installed(core_filename))
play_feature_delivery_delete(core_filename);
else
@ -7846,13 +7840,13 @@ static int action_ok_core_delete(const char *path,
* accumulation of mess, additionally check
* for and remove any such backups when deleting
* a core */
strlcpy(backup_core_path, core_path,
sizeof(backup_core_path));
strlcat(backup_core_path, FILE_PATH_BACKUP_EXTENSION,
_len = strlcpy(backup_core_path, core_path,
sizeof(backup_core_path));
strlcpy(backup_core_path + _len, FILE_PATH_BACKUP_EXTENSION,
sizeof(backup_core_path) - _len);
if (!string_is_empty(backup_core_path) &&
path_is_valid(backup_core_path))
if ( !string_is_empty(backup_core_path)
&& path_is_valid(backup_core_path))
filestream_delete(backup_core_path);
}
else

View File

@ -706,6 +706,7 @@ static int action_start_core_lock(
/* ...Otherwise, attempt to unlock it */
if (!core_info_set_core_lock(core_path, false))
{
size_t _len;
const char *core_name = NULL;
core_info_t *core_info = NULL;
char msg[PATH_MAX_LENGTH];
@ -721,10 +722,10 @@ static int action_start_core_lock(
core_name = path_basename_nocompression(core_path);
/* Build error message */
strlcpy(msg, msg_hash_to_str(MSG_CORE_UNLOCK_FAILED), sizeof(msg));
_len = strlcpy(msg, msg_hash_to_str(MSG_CORE_UNLOCK_FAILED), sizeof(msg));
if (!string_is_empty(core_name))
strlcat(msg, core_name, sizeof(msg));
strlcpy(msg + _len, core_name, sizeof(msg) - _len);
/* Generate log + notification */
RARCH_ERR("%s\n", msg);
@ -765,6 +766,7 @@ static int action_start_core_set_standalone_exempt(
/* ...Otherwise, attempt to unset the exempt flag */
if (!core_info_set_core_standalone_exempt(core_path, false))
{
size_t _len;
const char *core_name = NULL;
core_info_t *core_info = NULL;
char msg[PATH_MAX_LENGTH];
@ -780,12 +782,12 @@ static int action_start_core_set_standalone_exempt(
core_name = path_basename_nocompression(core_path);
/* Build error message */
strlcpy(msg,
_len = strlcpy(msg,
msg_hash_to_str(MSG_CORE_UNSET_STANDALONE_EXEMPT_FAILED),
sizeof(msg));
if (!string_is_empty(core_name))
strlcat(msg, core_name, sizeof(msg));
strlcpy(msg + _len, core_name, sizeof(msg) - _len);
/* Generate log + notification */
RARCH_ERR("%s\n", msg);

View File

@ -4148,7 +4148,8 @@ static void ozone_update_content_metadata(ozone_handle_t *ozone)
sizeof(ozone->selection_core_name));
ozone->selection_core_name[_len ] = ' ';
ozone->selection_core_name[_len+1] = '\0';
strlcat(ozone->selection_core_name, core_label, sizeof(ozone->selection_core_name));
_len += 1;
strlcpy(ozone->selection_core_name + _len, core_label, sizeof(ozone->selection_core_name) - _len);
if (!scroll_content_metadata)
linebreak_after_colon(&ozone->selection_core_name);
@ -4198,7 +4199,8 @@ static void ozone_update_content_metadata(ozone_handle_t *ozone)
sizeof(ozone->selection_playtime));
ozone->selection_playtime[_len ] = ' ';
ozone->selection_playtime[_len+1] = '\0';
strlcat(ozone->selection_playtime, disabled_str, sizeof(ozone->selection_playtime));
_len += 1;
strlcpy(ozone->selection_playtime + _len, disabled_str, sizeof(ozone->selection_playtime) - _len);
_len =
strlcpy(ozone->selection_lastplayed,
@ -4206,7 +4208,8 @@ static void ozone_update_content_metadata(ozone_handle_t *ozone)
sizeof(ozone->selection_lastplayed));
ozone->selection_lastplayed[_len ] = ' ';
ozone->selection_lastplayed[_len+1] = '\0';
strlcat(ozone->selection_lastplayed, disabled_str, sizeof(ozone->selection_lastplayed));
_len += 1;
strlcpy(ozone->selection_lastplayed + _len, disabled_str, sizeof(ozone->selection_lastplayed) - _len);
}
if (!scroll_content_metadata)
@ -9224,8 +9227,8 @@ static void ozone_context_reset(void *data, bool is_threaded)
#ifdef HAVE_DISCORD_OWN_AVATAR
if (i == OZONE_TEXTURE_DISCORD_OWN_AVATAR && discord_avatar_is_ready())
{
strlcpy(filename, discord_get_own_avatar(), sizeof(filename));
strlcat(filename, FILE_PATH_PNG_EXTENSION, sizeof(filename));
size_t _len = strlcpy(filename, discord_get_own_avatar(), sizeof(filename));
strlcpy(filename + _len, FILE_PATH_PNG_EXTENSION, sizeof(filename) - _len);
}
else
#endif

View File

@ -555,17 +555,18 @@ static int menu_displaylist_parse_core_info(
for (i = 0; i < ARRAY_SIZE(info_list); i++)
{
size_t len;
size_t _len;
if (!info_list[i].name)
continue;
len = strlcpy(tmp,
_len = strlcpy(tmp,
msg_hash_to_str(info_list[i].msg),
sizeof(tmp));
tmp[len ] = ':';
tmp[len+1] = ' ';
tmp[len+2] = '\0';
strlcat(tmp, info_list[i].name, sizeof(tmp));
tmp[_len ] = ':';
tmp[_len+1] = ' ';
tmp[_len+2] = '\0';
_len += 2;
strlcpy(tmp + _len, info_list[i].name, sizeof(tmp) - _len);
if (menu_entries_append(list, tmp, "",
MENU_ENUM_LABEL_CORE_INFO_ENTRY,
MENU_SETTINGS_CORE_INFO_NONE, 0, 0, NULL))
@ -575,12 +576,12 @@ static int menu_displaylist_parse_core_info(
if (core_info->categories_list)
{
size_t len = strlcpy(tmp,
size_t _len = strlcpy(tmp,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_CATEGORIES),
sizeof(tmp));
tmp[len ] = ':';
tmp[len+1] = ' ';
tmp[len+2] = '\0';
tmp[_len ] = ':';
tmp[_len+1] = ' ';
tmp[_len+2] = '\0';
string_list_join_concat(tmp, sizeof(tmp),
core_info->categories_list, ", ");
if (menu_entries_append(list, tmp, "",
@ -590,12 +591,12 @@ static int menu_displaylist_parse_core_info(
if (core_info->authors_list)
{
size_t len = strlcpy(tmp,
size_t _len = strlcpy(tmp,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_AUTHORS),
sizeof(tmp));
tmp[len ] = ':';
tmp[len+1] = ' ';
tmp[len+2] = '\0';
tmp[_len ] = ':';
tmp[_len+1] = ' ';
tmp[_len+2] = '\0';
string_list_join_concat(tmp, sizeof(tmp),
core_info->authors_list, ", ");
if (menu_entries_append(list, tmp, "",
@ -605,12 +606,12 @@ static int menu_displaylist_parse_core_info(
if (core_info->permissions_list)
{
size_t len = strlcpy(tmp,
size_t _len = strlcpy(tmp,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_PERMISSIONS),
sizeof(tmp));
tmp[len ] = ':';
tmp[len+1] = ' ';
tmp[len+2] = '\0';
tmp[_len ] = ':';
tmp[_len+1] = ' ';
tmp[_len+2] = '\0';
string_list_join_concat(tmp, sizeof(tmp),
core_info->permissions_list, ", ");
if (menu_entries_append(list, tmp, "",
@ -620,12 +621,12 @@ static int menu_displaylist_parse_core_info(
if (core_info->licenses_list)
{
size_t len = strlcpy(tmp,
size_t _len = strlcpy(tmp,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_LICENSES),
sizeof(tmp));
tmp[len ] = ':';
tmp[len+1] = ' ';
tmp[len+2] = '\0';
tmp[_len ] = ':';
tmp[_len+1] = ' ';
tmp[_len+2] = '\0';
string_list_join_concat(tmp, sizeof(tmp),
core_info->licenses_list, ", ");
if (menu_entries_append(list, tmp, "",
@ -635,13 +636,13 @@ static int menu_displaylist_parse_core_info(
if (core_info->supported_extensions_list)
{
size_t len = strlcpy(tmp,
size_t _len = strlcpy(tmp,
msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_CORE_INFO_SUPPORTED_EXTENSIONS),
sizeof(tmp));
tmp[len ] = ':';
tmp[len+1] = ' ';
tmp[len+2] = '\0';
tmp[_len ] = ':';
tmp[_len+1] = ' ';
tmp[_len+2] = '\0';
string_list_join_concat(tmp, sizeof(tmp),
core_info->supported_extensions_list, ", ");
if (menu_entries_append(list, tmp, "",
@ -651,12 +652,12 @@ static int menu_displaylist_parse_core_info(
if (core_info->required_hw_api)
{
size_t len = strlcpy(tmp,
size_t _len = strlcpy(tmp,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_REQUIRED_HW_API),
sizeof(tmp));
tmp[len ] = ':';
tmp[len+1] = ' ';
tmp[len+2] = '\0';
tmp[_len ] = ':';
tmp[_len+1] = ' ';
tmp[_len+2] = '\0';
string_list_join_concat(tmp, sizeof(tmp),
core_info->required_hw_api_list, ", ");
if (menu_entries_append(list, tmp, "",
@ -689,13 +690,14 @@ static int menu_displaylist_parse_core_info(
break;
}
{
size_t len = strlcpy(tmp,
size_t _len = strlcpy(tmp,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_SAVESTATE_SUPPORT_LEVEL),
sizeof(tmp));
tmp[len ] = ':';
tmp[len+1] = ' ';
tmp[len+2] = '\0';
strlcat(tmp, savestate_support, sizeof(tmp));
tmp[_len ] = ':';
tmp[_len+1] = ' ';
tmp[_len+2] = '\0';
_len += 2;
strlcpy(tmp + _len, savestate_support, sizeof(tmp) - _len);
}
if (menu_entries_append(list, tmp, "",
@ -2330,7 +2332,8 @@ static int create_string_list_rdb_entry_string(
tmp[_len ] = ':';
tmp[_len+1] = ' ';
tmp[_len+2] = '\0';
strlcat(tmp, actual_string, sizeof(tmp));
_len += 2;
strlcpy(tmp + _len, actual_string, sizeof(tmp) - _len);
menu_entries_append(list, tmp, output_label,
enum_idx,
0, 0, 0, NULL);
@ -2379,7 +2382,8 @@ static int create_string_list_rdb_entry_int(
tmp[_len ] = ':';
tmp[_len+1] = ' ';
tmp[_len+2] = '\0';
strlcat(tmp, str, sizeof(tmp));
_len += 2;
strlcpy(tmp + _len, str, sizeof(tmp) - _len);
menu_entries_append(list, tmp, output_label,
enum_idx,
0, 0, 0, NULL);
@ -2523,13 +2527,14 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
if (db_info_entry->name)
{
size_t len = strlcpy(tmp,
size_t _len = strlcpy(tmp,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_NAME),
sizeof(tmp));
tmp[len ] = ':';
tmp[len+1] = ' ';
tmp[len+2] = '\0';
strlcat(tmp, db_info_entry->name, sizeof(tmp));
tmp[_len ] = ':';
tmp[_len+1] = ' ';
tmp[_len+2] = '\0';
_len += 2;
strlcpy(tmp + _len, db_info_entry->name, sizeof(tmp) - _len);
menu_entries_append(info->list, tmp,
msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_NAME),
MENU_ENUM_LABEL_RDB_ENTRY_NAME,
@ -2538,13 +2543,13 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
if (db_info_entry->description)
{
size_t len = strlcpy(tmp,
size_t _len = strlcpy(tmp,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_DESCRIPTION),
sizeof(tmp));
tmp[len ] = ':';
tmp[len+1] = ' ';
tmp[len+2] = '\0';
strlcat(tmp, db_info_entry->description, sizeof(tmp));
tmp[_len ] = ':';
tmp[_len+1] = ' ';
tmp[_len+2] = '\0';
strlcpy(tmp + _len, db_info_entry->description, sizeof(tmp) - _len);
menu_entries_append(info->list, tmp,
msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_DESCRIPTION),
MENU_ENUM_LABEL_RDB_ENTRY_DESCRIPTION,
@ -2553,13 +2558,14 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
if (db_info_entry->genre)
{
size_t len = strlcpy(tmp,
size_t _len = strlcpy(tmp,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_GENRE),
sizeof(tmp));
tmp[len ] = ':';
tmp[len+1] = ' ';
tmp[len+2] = '\0';
strlcat(tmp, db_info_entry->genre, sizeof(tmp));
tmp[_len ] = ':';
tmp[_len+1] = ' ';
tmp[_len+2] = '\0';
_len += 2;
strlcpy(tmp + _len, db_info_entry->genre, sizeof(tmp) - _len);
menu_entries_append(info->list, tmp,
msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_GENRE),
MENU_ENUM_LABEL_RDB_ENTRY_GENRE,
@ -4783,7 +4789,8 @@ static unsigned menu_displaylist_parse_content_information(
tmp[_len ] = ':';
tmp[_len+1] = ' ';
tmp[_len+2] = '\0';
strlcat(tmp, db_name_no_ext, sizeof(tmp));
_len += 2;
strlcpy(tmp + _len, db_name_no_ext, sizeof(tmp) - _len);
if (menu_entries_append(info_list, tmp,
msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_INFO_DATABASE),
MENU_ENUM_LABEL_CONTENT_INFO_DATABASE,
@ -4797,19 +4804,18 @@ static unsigned menu_displaylist_parse_content_information(
if ( !(core_supports_no_game
&& string_is_empty(content_path)))
{
size_t _len;
/* Content label */
_len = strlcpy(tmp,
size_t _len = strlcpy(tmp,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_LABEL),
sizeof(tmp));
tmp[_len ] = ':';
tmp[_len+1] = ' ';
tmp[_len+2] = '\0';
strlcat(tmp, !string_is_empty(content_label)
_len += 2;
strlcpy(tmp + _len, !string_is_empty(content_label)
? content_label
: msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE),
sizeof(tmp));
sizeof(tmp) - _len);
if (menu_entries_append(info_list, tmp,
msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_INFO_LABEL),
MENU_ENUM_LABEL_CONTENT_INFO_LABEL,
@ -4823,10 +4829,11 @@ static unsigned menu_displaylist_parse_content_information(
tmp[_len ] = ':';
tmp[_len+1] = ' ';
tmp[_len+2] = '\0';
strlcat(tmp, !string_is_empty(content_path)
_len += 2;
strlcpy(tmp + _len, !string_is_empty(content_path)
? content_path
: msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE),
sizeof(tmp));
sizeof(tmp) - _len);
if (menu_entries_append(info_list, tmp,
msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_INFO_PATH),
MENU_ENUM_LABEL_CONTENT_INFO_PATH,
@ -4844,7 +4851,8 @@ static unsigned menu_displaylist_parse_content_information(
tmp[_len ] = ':';
tmp[_len+1] = ' ';
tmp[_len+2] = '\0';
strlcat(tmp, core_name, sizeof(tmp));
_len += 2;
strlcpy(tmp + _len, core_name, sizeof(tmp) - _len);
if (menu_entries_append(info_list, tmp,
msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_INFO_CORE_NAME),
MENU_ENUM_LABEL_CORE_INFORMATION, /* Shortcut to core info */
@ -6333,6 +6341,7 @@ static unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list)
for (i = 0; i < net_st->room_count; i++)
{
size_t _len;
struct netplay_room *room = &net_st->room_list[i];
/* Get rid of any room that is not running RetroArch. */
@ -6379,22 +6388,22 @@ static unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list)
{
if (!show_passworded)
continue;
strlcpy(passworded, "[", sizeof(passworded));
strlcat(passworded, msg_room_pwd, sizeof(passworded));
_len = strlcpy(passworded, "[", sizeof(passworded));
strlcpy(passworded + _len, msg_room_pwd, sizeof(passworded) - _len);
strlcat(passworded, "] ", sizeof(passworded));
}
else
*passworded = '\0';
strlcpy(buf, passworded, sizeof(buf));
strlcat(buf, room_type, sizeof(buf));
_len = strlcpy(buf, passworded, sizeof(buf));
strlcpy(buf + _len, room_type, sizeof(buf) - _len);
strlcat(buf, ": ", sizeof(buf));
strlcat(buf, room->nickname, sizeof(buf));
if (!room->lan && !string_is_empty(room->country))
{
strlcpy(country, " (", sizeof(country));
strlcat(country, room->country, sizeof(country));
_len = strlcpy(country, " (", sizeof(country));
strlcpy(country + _len, room->country, sizeof(country) - _len);
strlcat(country, ")", sizeof(country));
strlcat(buf, country, sizeof(buf));
}
@ -11476,7 +11485,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
sizeof(desc_label));
desc_label[_len ] = ' ';
desc_label[_len+1] = '\0';
strlcat(desc_label, descriptor, sizeof(desc_label));
_len += 1;
strlcpy(desc_label + _len, descriptor, sizeof(desc_label) - _len);
strlcpy(descriptor, desc_label, sizeof(descriptor));
}
@ -11528,7 +11538,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
sizeof(desc_label));
desc_label[_len ] = ' ';
desc_label[_len+1] = '\0';
strlcat(desc_label, descriptor, sizeof(desc_label));
_len += 1;
strlcpy(desc_label + _len, descriptor, sizeof(desc_label) - _len);
strlcpy(descriptor, desc_label, sizeof(descriptor));
}
@ -11635,10 +11646,10 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
if (!string_is_empty(cd_info.serial))
{
char serial[256];
strlcpy(serial,
size_t _len = strlcpy(serial,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_SERIAL),
sizeof(serial));
strlcat(serial, "#: ", sizeof(serial));
strlcpy(serial + _len, "#: ", sizeof(serial) - _len);
strlcat(serial, cd_info.serial, sizeof(serial));
if (menu_entries_append(info->list,
@ -12426,7 +12437,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
_len2 = strlcpy(buf, buf_tmp, sizeof(buf));
buf[_len2 ] = ' ';
buf[_len2+1] = '\0';
strlcat(buf, val_filter, sizeof(buf));
_len2 += 1;
strlcpy(buf + _len2, val_filter, sizeof(buf) - _len2);
if (menu_entries_append(info->list, buf, shdr_filter_pass,
MENU_ENUM_LABEL_VIDEO_SHADER_FILTER_PASS,
MENU_SETTINGS_SHADER_PASS_FILTER_0 + i, 0, 0, NULL))
@ -12435,7 +12447,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
_len2 = strlcpy(buf, buf_tmp, sizeof(buf));
buf[_len2 ] = ' ';
buf[_len2+1] = '\0';
strlcat(buf, val_scale, sizeof(buf));
_len2 += 1;
strlcpy(buf + _len2, val_scale, sizeof(buf) - _len2);
if (menu_entries_append(info->list, buf, shdr_scale_pass,
MENU_ENUM_LABEL_VIDEO_SHADER_SCALE_PASS,
MENU_SETTINGS_SHADER_PASS_SCALE_0 + i, 0, 0, NULL))

View File

@ -1048,12 +1048,15 @@ static void setting_get_string_representation_int_gpu_index(rarch_setting_t *set
if (setting)
{
struct string_list *list = video_driver_get_gpu_api_devices(video_context_driver_get_api());
snprintf(s, len, "%d", *setting->value.target.integer);
size_t _len = snprintf(s, len, "%d", *setting->value.target.integer);
if (list && (*setting->value.target.integer < (int)list->size) && !string_is_empty(list->elems[*setting->value.target.integer].data))
{
strlcat(s, " - ", len);
strlcat(s, list->elems[*setting->value.target.integer].data, len);
s[_len ] = ' ';
s[_len+1] = '-';
s[_len+2] = ' ';
s[_len+3] = '\0';
_len += 3;
strlcpy(s + _len, list->elems[*setting->value.target.integer].data, len - _len);
}
}
}
@ -6956,8 +6959,8 @@ static void setting_get_string_representation_uint_menu_screensaver_timeout(
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF), len);
else
{
snprintf(s, len, "%u ", *setting->value.target.unsigned_integer);
strlcat(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SECONDS), len);
size_t _len = snprintf(s, len, "%u ", *setting->value.target.unsigned_integer);
strlcpy(s + _len, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SECONDS), len - _len);
}
}

View File

@ -6507,10 +6507,12 @@ static enum runloop_state_enum runloop_check_state(
cur_state_slot);
_len = strlcpy(msg, msg_hash_to_str(MSG_STATE_SLOT), sizeof(msg));
snprintf(msg + _len, sizeof(msg) - _len,
": %d", settings->ints.state_slot);
if (cur_state_slot < 0)
strlcat(msg, " (Auto)", sizeof(msg));
snprintf(msg + _len, sizeof(msg) - _len,
": %d (Auto)", settings->ints.state_slot);
else
snprintf(msg + _len, sizeof(msg) - _len,
": %d", settings->ints.state_slot);
#ifdef HAVE_GFX_WIDGETS
if (dispwidget_get_ptr()->active)
@ -6567,10 +6569,12 @@ static enum runloop_state_enum runloop_check_state(
cur_replay_slot);
_len = strlcpy(msg, msg_hash_to_str(MSG_REPLAY_SLOT), sizeof(msg));
snprintf(msg + _len, sizeof(msg) - _len,
": %d", settings->ints.replay_slot);
if (cur_replay_slot < 0)
strlcat(msg, " (Auto)", sizeof(msg));
snprintf(msg + _len, sizeof(msg) - _len,
": %d (Auto)", settings->ints.replay_slot);
else
snprintf(msg + _len, sizeof(msg) - _len,
": %d", settings->ints.replay_slot);
#ifdef HAVE_GFX_WIDGETS
if (dispwidget_get_ptr()->active)

View File

@ -874,7 +874,8 @@ static void content_file_get_path(
content_path, sizeof(info_path));
info_path[_len ] = '#';
info_path[_len+1] = '\0';
strlcat(info_path, archive_file, sizeof(info_path));
_len += 1;
strlcpy(info_path + _len, archive_file, sizeof(info_path) - _len);
/* Update 'content' string_list */
string_list_set(content, (unsigned)idx, info_path);

View File

@ -743,15 +743,16 @@ static void task_core_updater_download_handler(retro_task_t *task)
if (download_handle->backup_task)
{
size_t _len;
char task_title[PATH_MAX_LENGTH];
/* Update task title */
task_free_title(task);
strlcpy(
_len = strlcpy(
task_title, msg_hash_to_str(MSG_BACKING_UP_CORE),
sizeof(task_title));
strlcat(task_title, download_handle->display_name, sizeof(task_title));
strlcpy(task_title + _len, download_handle->display_name, sizeof(task_title) - _len);
task_set_title(task, strdup(task_title));
@ -806,6 +807,7 @@ static void task_core_updater_download_handler(retro_task_t *task)
break;
case CORE_UPDATER_DOWNLOAD_START_TRANSFER:
{
size_t _len;
file_transfer_t *transf = NULL;
char task_title[PATH_MAX_LENGTH];
@ -828,10 +830,10 @@ static void task_core_updater_download_handler(retro_task_t *task)
/* Update task title */
task_free_title(task);
strlcpy(
_len = strlcpy(
task_title, msg_hash_to_str(MSG_DOWNLOADING_CORE),
sizeof(task_title));
strlcat(task_title, download_handle->display_name, sizeof(task_title));
strlcpy(task_title + _len, download_handle->display_name, sizeof(task_title) - _len);
task_set_title(task, strdup(task_title));
@ -875,15 +877,16 @@ static void task_core_updater_download_handler(retro_task_t *task)
* callback to trigger */
if (download_handle->http_task_complete)
{
size_t _len;
char task_title[PATH_MAX_LENGTH];
/* Update task title */
task_free_title(task);
strlcpy(
_len = strlcpy(
task_title, msg_hash_to_str(MSG_EXTRACTING_CORE),
sizeof(task_title));
strlcat(task_title, download_handle->display_name, sizeof(task_title));
strlcpy(task_title + _len, download_handle->display_name, sizeof(task_title) - _len);
task_set_title(task, strdup(task_title));
@ -932,13 +935,15 @@ static void task_core_updater_download_handler(retro_task_t *task)
break;
case CORE_UPDATER_DOWNLOAD_ERROR:
{
size_t _len;
char task_title[PATH_MAX_LENGTH];
/* Set final task title */
task_free_title(task);
strlcpy(task_title, msg_hash_to_str(MSG_CORE_INSTALL_FAILED), sizeof(task_title));
strlcat(task_title, download_handle->display_name, sizeof(task_title));
_len = strlcpy(task_title, msg_hash_to_str(MSG_CORE_INSTALL_FAILED), sizeof(task_title));
strlcpy(task_title + _len, download_handle->display_name,
sizeof(task_title) - _len);
task_set_title(task, strdup(task_title));
task_set_progress(task, 100);
@ -947,17 +952,19 @@ static void task_core_updater_download_handler(retro_task_t *task)
break;
case CORE_UPDATER_DOWNLOAD_END:
{
size_t _len;
char task_title[PATH_MAX_LENGTH];
/* Set final task title */
task_free_title(task);
strlcpy(
_len = strlcpy(
task_title,
download_handle->crc_match ?
msg_hash_to_str(MSG_LATEST_CORE_INSTALLED) : msg_hash_to_str(MSG_CORE_INSTALLED),
sizeof(task_title));
strlcat(task_title, download_handle->display_name, sizeof(task_title));
strlcpy(task_title + _len, download_handle->display_name,
sizeof(task_title) - _len);
task_set_title(task, strdup(task_title));
}
@ -996,6 +1003,7 @@ void *task_push_core_updater_download(
const char *path_dir_libretro,
const char *path_dir_core_assets)
{
size_t _len;
task_finder_data_t find_data;
char task_title[PATH_MAX_LENGTH];
char local_download_path[PATH_MAX_LENGTH];
@ -1015,9 +1023,9 @@ void *task_push_core_updater_download(
#endif
/* Sanity check */
if (!core_list ||
string_is_empty(filename) ||
!download_handle)
if ( !core_list
|| string_is_empty(filename)
|| !download_handle)
goto error;
/* Get core updater list entry */
@ -1044,8 +1052,8 @@ void *task_push_core_updater_download(
if (!mute)
{
char msg[PATH_MAX_LENGTH];
strlcpy(msg, msg_hash_to_str(MSG_CORE_UPDATE_DISABLED), sizeof(msg));
strlcat(msg, list_entry->display_name, sizeof(msg));
size_t _len = strlcpy(msg, msg_hash_to_str(MSG_CORE_UPDATE_DISABLED), sizeof(msg));
strlcpy(msg + _len, list_entry->display_name, sizeof(msg) - _len);
runloop_msg_queue_push(msg, 1, 100, true,
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
@ -1099,10 +1107,11 @@ void *task_push_core_updater_download(
goto error;
/* Configure task */
strlcpy(
_len = strlcpy(
task_title, msg_hash_to_str(MSG_UPDATING_CORE),
sizeof(task_title));
strlcat(task_title, download_handle->display_name, sizeof(task_title));
strlcpy(task_title + _len, download_handle->display_name,
sizeof(task_title) - _len);
task->handler = task_core_updater_download_handler;
task->state = download_handle;
@ -1247,10 +1256,11 @@ static void task_update_installed_cores_handler(retro_task_t *task)
if (core_installed)
{
char task_title[PATH_MAX_LENGTH];
strlcpy(
size_t _len = strlcpy(
task_title, msg_hash_to_str(MSG_CHECKING_CORE),
sizeof(task_title));
strlcat(task_title, list_entry->display_name, sizeof(task_title));
strlcpy(task_title + _len, list_entry->display_name,
sizeof(task_title) - _len);
task_set_title(task, strdup(task_title));
}
@ -1340,14 +1350,16 @@ static void task_update_installed_cores_handler(retro_task_t *task)
update_installed_handle->status = UPDATE_INSTALLED_CORES_ITERATE;
else
{
size_t _len;
char task_title[PATH_MAX_LENGTH];
/* Update task title */
task_free_title(task);
strlcpy(
_len = strlcpy(
task_title, msg_hash_to_str(MSG_UPDATING_CORE),
sizeof(task_title));
strlcat(task_title, list_entry->display_name, sizeof(task_title));
strlcpy(task_title + _len, list_entry->display_name,
sizeof(task_title) - _len);
task_set_title(task, strdup(task_title));
@ -1757,6 +1769,7 @@ static void task_play_feature_delivery_core_install_handler(
* play feature delivery transaction */
if (path_is_valid(pfd_install_handle->local_core_path))
{
size_t _len;
char backup_core_path[PATH_MAX_LENGTH];
bool backup_successful = false;
@ -1766,11 +1779,12 @@ static void task_play_feature_delivery_core_install_handler(
* run at a time, a UID is not required */
/* Generate backup file name */
strlcpy(backup_core_path,
_len = strlcpy(backup_core_path,
pfd_install_handle->local_core_path,
sizeof(backup_core_path));
strlcat(backup_core_path, FILE_PATH_BACKUP_EXTENSION,
sizeof(backup_core_path));
strlcpy(backup_core_path + _len,
FILE_PATH_BACKUP_EXTENSION,
sizeof(backup_core_path) - _len);
if (!string_is_empty(backup_core_path))
{
@ -1811,6 +1825,7 @@ static void task_play_feature_delivery_core_install_handler(
break;
case PLAY_FEATURE_DELIVERY_INSTALL_WAIT:
{
size_t _len;
enum play_feature_delivery_install_status install_status;
unsigned install_progress;
char task_title[PATH_MAX_LENGTH];
@ -1833,18 +1848,20 @@ static void task_play_feature_delivery_core_install_handler(
break;
case PLAY_FEATURE_DELIVERY_DOWNLOADING:
task_free_title(task);
strlcpy(task_title, msg_hash_to_str(MSG_DOWNLOADING_CORE),
sizeof(task_title));
strlcat(task_title, pfd_install_handle->display_name,
_len = strlcpy(task_title, msg_hash_to_str(MSG_DOWNLOADING_CORE),
sizeof(task_title));
strlcpy(task_title + _len,
pfd_install_handle->display_name,
sizeof(task_title) - _len);
task_set_title(task, strdup(task_title));
break;
case PLAY_FEATURE_DELIVERY_INSTALLING:
task_free_title(task);
strlcpy(task_title, msg_hash_to_str(MSG_INSTALLING_CORE),
sizeof(task_title));
strlcat(task_title, pfd_install_handle->display_name,
_len = strlcpy(task_title, msg_hash_to_str(MSG_INSTALLING_CORE),
sizeof(task_title));
strlcpy(task_title + _len,
pfd_install_handle->display_name,
sizeof(task_title) - _len);
task_set_title(task, strdup(task_title));
break;
default:
@ -1859,8 +1876,9 @@ static void task_play_feature_delivery_core_install_handler(
break;
case PLAY_FEATURE_DELIVERY_INSTALL_END:
{
const char *msg_str = msg_hash_to_str(MSG_CORE_INSTALL_FAILED);
size_t _len;
char task_title[PATH_MAX_LENGTH];
const char *msg_str = msg_hash_to_str(MSG_CORE_INSTALL_FAILED);
/* Set final task title */
task_free_title(task);
@ -1870,9 +1888,10 @@ static void task_play_feature_delivery_core_install_handler(
msg_hash_to_str(MSG_LATEST_CORE_INSTALLED) :
msg_hash_to_str(MSG_CORE_INSTALLED);
strlcpy(task_title, msg_str, sizeof(task_title));
strlcat(task_title, pfd_install_handle->display_name,
sizeof(task_title));
_len = strlcpy(task_title, msg_str, sizeof(task_title));
strlcpy(task_title + _len,
pfd_install_handle->display_name,
sizeof(task_title) - _len);
task_set_title(task, strdup(task_title));
@ -1933,6 +1952,7 @@ void *task_push_play_feature_delivery_core_install(
const char *filename,
bool mute)
{
size_t _len;
task_finder_data_t find_data;
char task_title[PATH_MAX_LENGTH];
const core_updater_list_entry_t *list_entry = NULL;
@ -1977,10 +1997,11 @@ void *task_push_play_feature_delivery_core_install(
goto error;
/* Configure task */
strlcpy(task_title, msg_hash_to_str(MSG_UPDATING_CORE),
sizeof(task_title));
strlcat(task_title, pfd_install_handle->display_name,
_len = strlcpy(task_title, msg_hash_to_str(MSG_UPDATING_CORE),
sizeof(task_title));
strlcpy(task_title + _len,
pfd_install_handle->display_name,
sizeof(task_title) - _len);
task->handler = task_play_feature_delivery_core_install_handler;
task->state = pfd_install_handle;
@ -2135,10 +2156,12 @@ static void task_play_feature_delivery_switch_cores_handler(
if (core_installed)
{
char task_title[PATH_MAX_LENGTH];
strlcpy(task_title, msg_hash_to_str(MSG_CHECKING_CORE),
sizeof(task_title));
strlcat(task_title, list_entry->display_name,
size_t _len = strlcpy(task_title,
msg_hash_to_str(MSG_CHECKING_CORE),
sizeof(task_title));
strlcpy(task_title + _len,
list_entry->display_name,
sizeof(task_title) - _len);
task_set_title(task, strdup(task_title));
}
else
@ -2197,15 +2220,18 @@ static void task_play_feature_delivery_switch_cores_handler(
PLAY_FEATURE_DELIVERY_SWITCH_CORES_ITERATE;
else
{
size_t _len;
char task_title[PATH_MAX_LENGTH];
/* Update task title */
task_free_title(task);
strlcpy(task_title, msg_hash_to_str(MSG_UPDATING_CORE),
sizeof(task_title));
strlcat(task_title, list_entry->display_name,
_len = strlcpy(task_title,
msg_hash_to_str(MSG_UPDATING_CORE),
sizeof(task_title));
strlcpy(task_title + _len,
list_entry->display_name,
sizeof(task_title) - _len);
task_set_title(task, strdup(task_title));

View File

@ -380,12 +380,13 @@ void* task_push_http_transfer_file(const char* url, bool mute,
len = strlcpy(tmp, msg_hash_to_str(MSG_DOWNLOADING), sizeof(tmp));
tmp[len ] = ' ';
tmp[len+1] = '\0';
len += 1;
if (string_ends_with_size(s, ".index",
strlen(s), STRLEN_CONST(".index")))
s = msg_hash_to_str(MSG_INDEX_FILE);
strlcat(tmp, s, sizeof(tmp));
strlcpy(tmp + len, s, sizeof(tmp) - len);
t->title = strdup(tmp);
return t;