From fb5d281eaf0fd8122198d92a9045e16d3826fef0 Mon Sep 17 00:00:00 2001 From: janisozaur Date: Fri, 15 Apr 2016 19:17:45 +0200 Subject: [PATCH] Check return value from realpath(). Fixes #2483 (#3309) --- src/platform/posix.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/platform/posix.c b/src/platform/posix.c index 850ad1df5a..d7984e2b92 100644 --- a/src/platform/posix.c +++ b/src/platform/posix.c @@ -658,7 +658,10 @@ void platform_resolve_user_data_path() const char separator[2] = { platform_get_path_separator(), 0 }; if (gCustomUserDataPath[0] != 0) { - realpath(gCustomUserDataPath, _userDataDirectoryPath); + if (realpath(gCustomUserDataPath, _userDataDirectoryPath) == NULL) { + log_error("Could not resolve path \"%s\"", gCustomUserDataPath); + return; + } // Ensure path ends with separator int len = strlen(_userDataDirectoryPath); @@ -703,7 +706,10 @@ void platform_resolve_openrct_data_path() const char separator[2] = { platform_get_path_separator(), 0 }; if (gCustomOpenrctDataPath[0] != 0) { - realpath(gCustomOpenrctDataPath, _openrctDataDirectoryPath); + if (realpath(gCustomOpenrctDataPath, _openrctDataDirectoryPath)) { + log_error("Could not resolve path \"%s\"", gCustomUserDataPath); + return; + } // Ensure path ends with separator int len = strlen(_openrctDataDirectoryPath);