From bc869f1be9b2129663dd34f4281a2abd34a5e9ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 12 Dec 2025 09:03:18 +0800 Subject: [PATCH] Chore: refines usage of `PATH_MAX` --- src/detection/brightness/brightness_linux.c | 2 +- src/util/platform/FFPlatform_unix.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/detection/brightness/brightness_linux.c b/src/detection/brightness/brightness_linux.c index 678c89a6a..da6825111 100644 --- a/src/detection/brightness/brightness_linux.c +++ b/src/detection/brightness/brightness_linux.c @@ -41,7 +41,7 @@ static const char* detectWithBacklight(FFlist* result) FFBrightnessResult* brightness = (FFBrightnessResult*) ffListAdd(result); ffStrbufSubstrBeforeLastC(&backlightDir, '/'); ffStrbufAppendS(&backlightDir, "/device"); - ffStrbufInitA(&brightness->name, PATH_MAX + 1); + ffStrbufInitA(&brightness->name, PATH_MAX); if(realpath(backlightDir.chars, brightness->name.chars)) { ffStrbufRecalculateLength(&brightness->name); diff --git a/src/util/platform/FFPlatform_unix.c b/src/util/platform/FFPlatform_unix.c index 85e624a0d..5badc958b 100644 --- a/src/util/platform/FFPlatform_unix.c +++ b/src/util/platform/FFPlatform_unix.c @@ -22,7 +22,7 @@ static void getExePath(FFPlatform* platform) { - char exePath[PATH_MAX + 1]; + char exePath[PATH_MAX]; #if defined(__linux__) || defined (__GNU__) ssize_t exePathLen = readlink("/proc/self/exe", exePath, sizeof(exePath) - 1); if (exePathLen >= 0) @@ -58,7 +58,7 @@ static void getExePath(FFPlatform* platform) while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) { if (info.type == B_APP_IMAGE) { - exePathLen = strlcpy(exePath, info.name, PATH_MAX); + exePathLen = strlcpy(exePath, info.name, sizeof(exePath)); break; } }