libretro / RetroArch

Cross-platform, sophisticated frontend for the libretro API. Licensed GPLv3.
http://www.libretro.com
GNU General Public License v3.0
10.31k stars 1.83k forks source link

--appendconfig failing with long input #12906

Closed herbymachine closed 2 years ago

herbymachine commented 3 years ago

Description

Command line option --appendconfig fails to apply all config files when a certain command line length is reached.

Expected behavior

Appendconfig applies all config files regardless how long the total input.

Actual behavior

When the appendconfig limit is reached, all subsequent config files are not applied.

Example:

/usr/bin/retroarch -v --appendconfig "/home/retrogamer/.config/retroarch/appendconfig/DEFAULT.cfg|/home/retrogamer/.config/retroarch/appendconfig/Platform/Sony_PlayStation.cfg|/home/retrogamer/.config/retroarch/appendconfig/Core/Beetle_PSX_HW.cfg|/home/retrogamer/.config/retroarch/appendconfig/Game/Sony_PlayStation/Tekken (USA).cfg" -L /usr/lib64/libretro/mednafen_psx_hw_libretro.so "/home/retrogamer/retromachine/games_1/Sony_PlayStation/Tekken (USA).m3u"

[INFO] [Config]: Loading default config. [INFO] [Config]: Looking for config in: "/home/retrogamer/.config/retroarch/retroarch.cfg". [INFO] [Config]: Appending config "/home/retrogamer/.config/retroarch/appendconfig/DEFAULT.cfg". [INFO] [Config]: Appending config "/home/retrogamer/.config/retroarch/appendconfig/Platform/Sony_PlayStation.cfg". [INFO] [Config]: Appending config "/home/retrogamer/.config/retroarch/appendconfig/Core/Beetle_PSX_HW.cfg". [INFO] [Config]: Appending config "/home/retrogamer/.config/retroarch/appendconfi". [ERROR] [Config]: Failed to append config "/home/retrogamer/.config/retroarch/appendconfi".

Steps to reproduce the bug

  1. Launch retroarch from the command line with the --appendconfig option and a long / multiple config string.
  2. Observe [ERROR] [Config]: Failed to append config in the output.

Bisect Results

Difficult to tell. However, this might be caused in function config_load_file in RetroArch/configuration.c. append_config_path is stored in temporary variable with an arbitrary size char tmp_append_path[PATH_MAX_LENGTH] and not checking the actual size of the commanding option. That's ok if only one config file is specified but could cause problems when multiple config files are specified. I could be wrong.

Version/Commit

Environment information

bslenul commented 3 years ago

Happening on Windows as well: https://www.reddit.com/r/RetroArch/comments/pqy6ha/retroarch_198_and_199_failing_to_load/

Started with 28417a02b7374308436b4d3f3b609cebb7cc88cf