Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure readlink uses correct buffer size in get_exec_name #725

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dannlee
Copy link

@dannlee dannlee commented Dec 24, 2024

There is an issue with the get_exec_name function where the executable name could be truncated if the total path length exceeded 32 characters.

The readlink function was using p_exec_name_maxsize (32) as the buffer size for the global buffer g_buffer (4096).
When the path to the /proc/[pid]/exe link exceeded 32 characters, readlink truncated the output, causing incorrect or incomplete executable names.

Updated the readlink call to use the buffer size: sizeof(g_buffer) - 1.
This prevents the truncation of the executable path during the readlink operation.
The executable name is still limited to under 32 characters when copied to p_exec_name via:
strncpy(p_exec_name, l_name_ptr + 1, p_exec_name_maxsize - 1);

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