Skip to content

Commit

Permalink
Replace some more strlcat calls
Browse files Browse the repository at this point in the history
  • Loading branch information
LibretroAdmin committed Jul 16, 2023
1 parent bd090de commit 4b6bd83
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
6 changes: 3 additions & 3 deletions libretro-common/file/file_path.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,16 @@ bool path_is_compressed_file(const char* path)
size_t fill_pathname(char *out_path, const char *in_path,
const char *replace, size_t size)
{
size_t _len, _len2;
size_t _len;
char tmp_path[PATH_MAX_LENGTH];
char *tok = NULL;
strlcpy(tmp_path, in_path, sizeof(tmp_path));
if ((tok = (char*)strrchr(path_basename(tmp_path), '.')))
*tok = '\0';

_len = strlcpy(out_path, tmp_path, size);
_len2 = strlcpy(out_path + _len, replace, size - _len);
return _len + _len2;
_len += strlcpy(out_path + _len, replace, size - _len);
return _len;
}


Expand Down
19 changes: 14 additions & 5 deletions menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -2252,17 +2252,21 @@ static int menu_displaylist_parse_playlist(

if (!string_is_empty(entry->path))
{
size_t _len;
/* Standard playlist entry
* > Base menu entry label is always playlist label
* > If playlist label is NULL, fallback to playlist entry file name
* > If required, add currently associated core (if any), otherwise
* no further action is necessary */

if (string_is_empty(entry->label))
fill_pathname(menu_entry_label,
path_basename(entry->path), "", sizeof(menu_entry_label));
_len = fill_pathname(menu_entry_label,
path_basename(entry->path), "",
sizeof(menu_entry_label));
else
strlcpy(menu_entry_label, entry->label, sizeof(menu_entry_label));
_len = strlcpy(menu_entry_label,
entry->label,
sizeof(menu_entry_label));

if (sanitization)
(*sanitization)(menu_entry_label);
Expand All @@ -2275,8 +2279,13 @@ static int menu_displaylist_parse_playlist(
&& !string_is_empty(entry->core_path)
&& !string_is_equal(entry->core_path, "DETECT"))
{
strlcat(menu_entry_label, label_spacer, sizeof(menu_entry_label));
strlcat(menu_entry_label, entry->core_name, sizeof(menu_entry_label));
_len += strlcpy(
menu_entry_label + _len,
label_spacer,
sizeof(menu_entry_label) - _len);
strlcpy(menu_entry_label + _len,
entry->core_name,
sizeof(menu_entry_label) - _len);
}
}

Expand Down

0 comments on commit 4b6bd83

Please sign in to comment.