Skip to content

fix(initsystem): prevent in-place buffer mutation when resolving symlinked init executable - #2717

Open
pro-laxmi wants to merge 1 commit into
fastfetch-cli:devfrom
pro-laxmi:fix/initsystem-basename-mod
Open

pro-laxmi wants to merge 1 commit into
fastfetch-cli:devfrom
pro-laxmi:fix/initsystem-basename-mod

Conversation

@pro-laxmi

Copy link
Copy Markdown

Summary of Changes

In src/detection/initsystem/initsystem_linux.c:
<libgen.h> defines POSIX basename(char *path), which is permitted by the standard to modify its argument in place. Calling basename(result->exe.chars) directly risked mutating result->exe.chars in place, stripping directory information from result->exe.

Fix

Use a separate stack buffer baseBuf for the basename() call before updating result->name and result->exe.

Verification & Testing

  • Built and ran tests via CTest (ctest --test-dir build); all 20 tests passed cleanly.
  • Verified ./build/fastfetch --initsystem executes with accurate init system detection.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant