gfx/menu: never strlcpy a buffer onto itself in the shader wildcard and XMB entry paths

Apple's fortified strlcpy() aborts when the source and destination
overlap, so an in-place copy is a crash on macOS rather than a no-op.
The $CONTENT-DIR$ and $PRESET-DIR$ wildcard expansions copied the
directory name onto itself through path_basename_nocompression(),
which returns its input unchanged now that fill_pathname_parent_dir_name()
produces a bare name; the copy is dropped. XMB's content-list entry
stripping now sources fill_pathname() from entry.path instead of
shifting the scratch copy in place.
This commit is contained in:
libretroadmin committed 2026-09-07 21:05:59 +02:00
1 parent 86c77bfc8e
commit dc82a34bba
2 files changed
+6 -10

No files matched your search

+3 -8
View File
@@ -209,10 +209,9 @@ static void video_shader_replace_wildcards_impl(
fill_pathname_parent_dir_name(content_dir_name,
rarch_path_basename,
sizeof(content_dir_name));
if (content_dir_name[0] != '\0')
strlcpy(content_dir_name,
path_basename_nocompression(content_dir_name),
sizeof(content_dir_name));
/* fill_pathname_parent_dir_name() yields a bare
* directory name, so there is no directory part
* left to strip here. */
if (content_dir_name[0] != '\0')
path_remove_extension(content_dir_name);
@@ -298,10 +297,6 @@ static void video_shader_replace_wildcards_impl(
char preset_dir_name[DIR_MAX_LENGTH];
fill_pathname_parent_dir_name(preset_dir_name,
in_preset_path, sizeof(preset_dir_name));
if (preset_dir_name[0] != '\0')
strlcpy(preset_dir_name,
path_basename_nocompression(preset_dir_name),
sizeof(preset_dir_name));
if (preset_dir_name[0] != '\0')
path_remove_extension(preset_dir_name);
if (preset_dir_name[0] != '\0')
+3 -2
View File
@@ -5953,8 +5953,9 @@ XMB_NOINLINE static int xmb_draw_item(
* buffer sits in a frame that is entered once per visible entry
* per frame. */
char entry_path[sizeof(entry.path)];
strlcpy(entry_path, entry.path, sizeof(entry_path));
fill_pathname(entry_path, path_basename(entry_path), "",
/* Source from entry.path so the copy never overlaps its own
* destination; fortified strlcpy() traps on overlap. */
fill_pathname(entry_path, path_basename(entry.path), "",
sizeof(entry_path));
if (*entry_path)
strlcpy(entry.path, entry_path, sizeof(entry.path));