diff --git a/native/jni/su/su_daemon.cpp b/native/jni/su/su_daemon.cpp index 4e5610867..1906ff804 100644 --- a/native/jni/su/su_daemon.cpp +++ b/native/jni/su/su_daemon.cpp @@ -314,7 +314,9 @@ void su_daemon_handler(int client, const sock_cred *cred) { umask(022); char path[32]; snprintf(path, sizeof(path), "/proc/%d/cwd", ctx.pid); - chdir(path); + char cwd[PATH_MAX]; + if (realpath(path, cwd)) + chdir(cwd); snprintf(path, sizeof(path), "/proc/%d/environ", ctx.pid); char buf[4096] = { 0 }; int fd = xopen(path, O_RDONLY);