fix(initsystem): avoid mutating path buffer with POSIX basename

This commit is contained in:
pro-laxmi authored and Carter Li committed 2026-11-14 12:35:33 +08:00
1 parent c6c8bffbab
commit 2b299cf97a
1 file changed
+3 -1
+3 -1
View File
@@ -39,8 +39,10 @@ const char* ffDetectInitSystem(FFInitSystemResult* result) {
// In some old system, /sbin/init is a symlink
char buf[PATH_MAX];
if (realpath(result->exe.chars, buf)) {
char baseBuf[PATH_MAX];
ffStrCopy(baseBuf, buf, sizeof(baseBuf));
ffStrbufSetS(&result->name, basename(baseBuf));
ffStrbufSetS(&result->exe, buf);
ffStrbufSetS(&result->name, basename(result->exe.chars));
}
}