mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
SDL: Fix bug where config file path could exceed maximum path length.
The fix is the change in the MAXPATHLEN check, but have also migrated this to Common::String to make the fix easier. Thanks to klusark for pointing out this problem.
This commit is contained in:
@@ -80,15 +80,16 @@ bool OSystem_POSIX::hasFeature(Feature f) {
|
||||
}
|
||||
|
||||
Common::String OSystem_POSIX::getDefaultConfigFileName() {
|
||||
char configFile[MAXPATHLEN];
|
||||
Common::String configFile;
|
||||
|
||||
// On POSIX type systems, by default we store the config file inside
|
||||
// to the HOME directory of the user.
|
||||
const char *home = getenv("HOME");
|
||||
if (home != NULL && strlen(home) < MAXPATHLEN)
|
||||
snprintf(configFile, MAXPATHLEN, "%s/%s", home, _baseConfigName.c_str());
|
||||
else
|
||||
strcpy(configFile, _baseConfigName.c_str());
|
||||
if (home != NULL && (strlen(home) + 1 + _baseConfigName.size()) < MAXPATHLEN) {
|
||||
configFile = Common::String::format("%s/%s", home, _baseConfigName.c_str());
|
||||
} else {
|
||||
configFile = _baseConfigName;
|
||||
}
|
||||
|
||||
return configFile;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user