From 52970e2d13647dbe0d87d855df22a2e838a51048 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Thu, 11 Jun 2026 10:15:25 +0800 Subject: [PATCH] Processing (Linux): don't use `/proc/pid/exe` as exePath when the file is not executable (no permission) --- src/common/impl/FFPlatform_unix.c | 4 ++-- src/common/impl/processing_linux.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/impl/FFPlatform_unix.c b/src/common/impl/FFPlatform_unix.c index de69f6bef..3b9c87db7 100644 --- a/src/common/impl/FFPlatform_unix.c +++ b/src/common/impl/FFPlatform_unix.c @@ -30,7 +30,7 @@ static void getExePath(FFPlatform* platform) { char exePath[PATH_MAX]; #if defined(__linux__) || defined(__GNU__) ssize_t exePathLen = readlink("/proc/self/exe", exePath, sizeof(exePath) - 1); - if (exePathLen >= 0) { + if (exePathLen > 0) { exePath[exePathLen] = '\0'; } #elif defined(__APPLE__) @@ -128,7 +128,7 @@ static void getExePath(FFPlatform* platform) { } #elif defined(__sun) ssize_t exePathLen = readlink("/proc/self/path/a.out", exePath, sizeof(exePath) - 1); - if (exePathLen >= 0) { + if (exePathLen > 0) { exePath[exePathLen] = '\0'; } #elif defined(__HAIKU__) diff --git a/src/common/impl/processing_linux.c b/src/common/impl/processing_linux.c index 2b87c3b79..06524f729 100644 --- a/src/common/impl/processing_linux.c +++ b/src/common/impl/processing_linux.c @@ -269,7 +269,7 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons } } - if (exePath->length == 0) { + if (exePath->length == 0 && access(filePath, X_OK) == 0) { ffStrbufSetS(exePath, filePath); } }