summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2018-11-22 23:21:03 -0300
committerJuan Linietsky <reduzio@gmail.com>2018-11-22 23:21:03 -0300
commit8ba0d513fa0068a241a25fbb6db09315fa3309cc (patch)
tree31043d26f857d06d30a8387e833654c1db1dea09
parentcdafb7bce2f0c9961cd84453b471345fe10c3043 (diff)
Added missing path verification on Unix, closes #20762
-rw-r--r--drivers/unix/dir_access_unix.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp
index 929e67faa9..e4b652cdce 100644
--- a/drivers/unix/dir_access_unix.cpp
+++ b/drivers/unix/dir_access_unix.cpp
@@ -328,6 +328,17 @@ Error DirAccessUnix::change_dir(String p_dir) {
return ERR_INVALID_PARAMETER;
}
+ String base = _get_root_path();
+ if (base != String()) {
+ ERR_FAIL_COND_V(getcwd(real_current_dir_name, 2048) == NULL, ERR_BUG);
+ String new_dir;
+ new_dir.parse_utf8(real_current_dir_name);
+
+ if (!new_dir.begins_with(base)) {
+ try_dir = current_dir; //revert
+ }
+ }
+
// the directory exists, so set current_dir to try_dir
current_dir = try_dir;
ERR_FAIL_COND_V(chdir(prev_dir.utf8().get_data()) != 0, ERR_BUG);