Guarantee space for string characters after strlcpy

to silence a couple of stringop-overflow warnings (3DS).
This commit is contained in:
pstef 2025-03-28 11:11:09 +00:00
parent 59a0665a20
commit 83e974077f
10 changed files with 13 additions and 13 deletions

View file

@ -4475,7 +4475,7 @@ bool config_load_override(void *data)
char tmp_path[PATH_MAX_LENGTH];
size_t _len = strlcpy(tmp_path,
path_get(RARCH_PATH_CONFIG_OVERRIDE),
sizeof(tmp_path));
sizeof(tmp_path) - 2);
tmp_path[ _len] = '|';
tmp_path[++_len] = '\0';
strlcpy(tmp_path + _len, core_path, sizeof(tmp_path) - _len);
@ -4503,7 +4503,7 @@ bool config_load_override(void *data)
char tmp_path[PATH_MAX_LENGTH];
size_t _len = strlcpy(tmp_path,
path_get(RARCH_PATH_CONFIG_OVERRIDE),
sizeof(tmp_path));
sizeof(tmp_path) - 2);
tmp_path[ _len] = '|';
tmp_path[++_len] = '\0';
strlcpy(tmp_path + _len, content_path, sizeof(tmp_path) - _len);
@ -4529,7 +4529,7 @@ bool config_load_override(void *data)
char tmp_path[PATH_MAX_LENGTH];
size_t _len = strlcpy(tmp_path,
path_get(RARCH_PATH_CONFIG_OVERRIDE),
sizeof(tmp_path));
sizeof(tmp_path) - 2);
tmp_path[ _len] = '|';
tmp_path[++_len] = '\0';
strlcpy(tmp_path + _len, game_path, sizeof(tmp_path) - _len);

View file

@ -1204,7 +1204,7 @@ core_option_manager_t *core_option_manager_new(
}
else
{
size_t __len = strlcpy(address, category_key, sizeof(address));
size_t __len = strlcpy(address, category_key, sizeof(address) - 3);
address[ __len] = ':';
address[++__len] = '#';
address[++__len] = '\0';

View file

@ -623,7 +623,7 @@ bool disk_control_append_image(
goto error;
/* Display log */
_len = strlcpy(msg, msg_hash_to_str(MSG_APPENDED_DISK), sizeof(msg));
_len = strlcpy(msg, msg_hash_to_str(MSG_APPENDED_DISK), sizeof(msg) - 3);
msg[ _len] = ':';
msg[++_len] = ' ';
msg[++_len] = '\0';
@ -653,7 +653,7 @@ error:
disk_control_set_eject_state(disk_control, false, false);
_len = strlcpy(msg,
msg_hash_to_str(MSG_FAILED_TO_APPEND_DISK), sizeof(msg));
msg_hash_to_str(MSG_FAILED_TO_APPEND_DISK), sizeof(msg) - 3);
msg[ _len] = ':';
msg[++_len] = ' ';
msg[++_len] = '\0';

View file

@ -4692,7 +4692,7 @@ static void rgui_render_osk(
* If OSK cannot physically fit on the screen,
* fallback to old style 'message box' implementation */
char msg[NAME_MAX_LENGTH];
size_t _len = strlcpy(msg, input_label, sizeof(msg));
size_t _len = strlcpy(msg, input_label, sizeof(msg) - 2);
msg[ _len] = '\n';
msg[++_len] = '\0';
strlcpy(msg + _len,

View file

@ -8418,7 +8418,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
{
const char *str = menu_input_dialog_get_buffer();
const char *label = menu_st->input_dialog_kb_label;
size_t _len = strlcpy(msg, label, sizeof(msg));
size_t _len = strlcpy(msg, label, sizeof(msg) - 2);
msg[ _len] = '\n';
msg[++_len] = '\0';
strlcpy(msg + _len,

View file

@ -124,7 +124,7 @@ static void contentless_cores_init_info_entries(
(contentless_core_info_entry_t*)malloc(sizeof(*entry));
size_t _len = strlcpy(licenses_str,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_LICENSES),
sizeof(licenses_str));
sizeof(licenses_str) - 3);
licenses_str[ _len] = ':';
licenses_str[++_len] = ' ';
licenses_str[++_len] = '\0';

View file

@ -5238,7 +5238,7 @@ static unsigned menu_displaylist_parse_content_information(
{
const char *cheevos_hash_str =
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_CHEEVOS_HASH);
size_t _len = strlcpy(tmp, cheevos_hash_str, sizeof(tmp));
size_t _len = strlcpy(tmp, cheevos_hash_str, sizeof(tmp) - 4);
tmp[ _len] = ':';
tmp[++_len] = ' ';
tmp[++_len] = '\n';

View file

@ -867,7 +867,7 @@ static void content_file_get_path(
char info_path[PATH_MAX_LENGTH];
/* Build 'complete' archive file path */
size_t _len = strlcpy(info_path,
content_path, sizeof(info_path));
content_path, sizeof(info_path) - 2);
info_path[_len ] = '#';
info_path[_len+1] = '\0';
_len += 1;

View file

@ -855,7 +855,7 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename)
lgame_id[1] = '\0';
strncpy(rgame_id, &raw_game_id[1], __len - 1);
rgame_id[__len - 1] = '\0';
_len = strlcpy(pre_game_id, lgame_id, sizeof(pre_game_id));
_len = strlcpy(pre_game_id, lgame_id, sizeof(pre_game_id) - 2);
pre_game_id[ _len] = '-';
pre_game_id[++_len] = '\0';
strlcpy(pre_game_id + _len, rgame_id, sizeof(pre_game_id) - _len);

View file

@ -558,7 +558,7 @@ static void task_save_handler(retro_task_t *task)
{
size_t _len = strlcpy(msg,
msg_hash_to_str(MSG_FAILED_TO_SAVE_STATE_TO),
sizeof(msg));
sizeof(msg) - 2);
msg[ _len] = ' ';
msg[++_len] = '\0';
strlcpy(msg + _len, state->path, sizeof(msg) - _len);