Skip to content

Commit 52970e2

Browse files
committed
Processing (Linux): don't use /proc/pid/exe as exePath when the file is not executable (no permission)
1 parent 4594734 commit 52970e2

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/common/impl/FFPlatform_unix.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static void getExePath(FFPlatform* platform) {
3030
char exePath[PATH_MAX];
3131
#if defined(__linux__) || defined(__GNU__)
3232
ssize_t exePathLen = readlink("/proc/self/exe", exePath, sizeof(exePath) - 1);
33-
if (exePathLen >= 0) {
33+
if (exePathLen > 0) {
3434
exePath[exePathLen] = '\0';
3535
}
3636
#elif defined(__APPLE__)
@@ -128,7 +128,7 @@ static void getExePath(FFPlatform* platform) {
128128
}
129129
#elif defined(__sun)
130130
ssize_t exePathLen = readlink("/proc/self/path/a.out", exePath, sizeof(exePath) - 1);
131-
if (exePathLen >= 0) {
131+
if (exePathLen > 0) {
132132
exePath[exePathLen] = '\0';
133133
}
134134
#elif defined(__HAIKU__)

src/common/impl/processing_linux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ void ffProcessGetInfoLinux(pid_t pid, FFstrbuf* processName, FFstrbuf* exe, cons
269269
}
270270
}
271271

272-
if (exePath->length == 0) {
272+
if (exePath->length == 0 && access(filePath, X_OK) == 0) {
273273
ffStrbufSetS(exePath, filePath);
274274
}
275275
}

0 commit comments

Comments
 (0)