Replace some more strlcat calls

This commit is contained in:
libretroadmin 2023-07-16 18:33:34 +02:00
parent bd090dea71
commit 4b6bd83780
2 changed files with 17 additions and 8 deletions

View File

@ -328,7 +328,7 @@ bool path_is_compressed_file(const char* path)
size_t fill_pathname(char *out_path, const char *in_path, size_t fill_pathname(char *out_path, const char *in_path,
const char *replace, size_t size) const char *replace, size_t size)
{ {
size_t _len, _len2; size_t _len;
char tmp_path[PATH_MAX_LENGTH]; char tmp_path[PATH_MAX_LENGTH];
char *tok = NULL; char *tok = NULL;
strlcpy(tmp_path, in_path, sizeof(tmp_path)); strlcpy(tmp_path, in_path, sizeof(tmp_path));
@ -336,8 +336,8 @@ size_t fill_pathname(char *out_path, const char *in_path,
*tok = '\0'; *tok = '\0';
_len = strlcpy(out_path, tmp_path, size); _len = strlcpy(out_path, tmp_path, size);
_len2 = strlcpy(out_path + _len, replace, size - _len); _len += strlcpy(out_path + _len, replace, size - _len);
return _len + _len2; return _len;
} }

View File

@ -2252,6 +2252,7 @@ static int menu_displaylist_parse_playlist(
if (!string_is_empty(entry->path)) if (!string_is_empty(entry->path))
{ {
size_t _len;
/* Standard playlist entry /* Standard playlist entry
* > Base menu entry label is always playlist label * > Base menu entry label is always playlist label
* > If playlist label is NULL, fallback to playlist entry file name * > If playlist label is NULL, fallback to playlist entry file name
@ -2259,10 +2260,13 @@ static int menu_displaylist_parse_playlist(
* no further action is necessary */ * no further action is necessary */
if (string_is_empty(entry->label)) if (string_is_empty(entry->label))
fill_pathname(menu_entry_label, _len = fill_pathname(menu_entry_label,
path_basename(entry->path), "", sizeof(menu_entry_label)); path_basename(entry->path), "",
sizeof(menu_entry_label));
else else
strlcpy(menu_entry_label, entry->label, sizeof(menu_entry_label)); _len = strlcpy(menu_entry_label,
entry->label,
sizeof(menu_entry_label));
if (sanitization) if (sanitization)
(*sanitization)(menu_entry_label); (*sanitization)(menu_entry_label);
@ -2275,8 +2279,13 @@ static int menu_displaylist_parse_playlist(
&& !string_is_empty(entry->core_path) && !string_is_empty(entry->core_path)
&& !string_is_equal(entry->core_path, "DETECT")) && !string_is_equal(entry->core_path, "DETECT"))
{ {
strlcat(menu_entry_label, label_spacer, sizeof(menu_entry_label)); _len += strlcpy(
strlcat(menu_entry_label, entry->core_name, sizeof(menu_entry_label)); menu_entry_label + _len,
label_spacer,
sizeof(menu_entry_label) - _len);
strlcpy(menu_entry_label + _len,
entry->core_name,
sizeof(menu_entry_label) - _len);
} }
} }