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

Fix: handle empty /proc/[PID]/cmdline properly #104

Closed
wants to merge 1 commit into from

Conversation

oToToT
Copy link
Contributor

@oToToT oToToT commented May 4, 2021

In some rare cases, the file /proc/[PID]/cmdline might be empty. This causes nvtop display wrong information about command being executed or even leak some data inside current memory.

For example, it might leak something similar to /etc/passwd.
image

I'm not sure how htop or ps handle this kind of case, but I think it's OK to display nothing in command section as it's actually empty there.

In some rare cases, the file /proc/[PID]/cmdline might be empty. This
cause nvtop display wrong information about command being executed or
even leak some data inside current memory.
@oToToT
Copy link
Contributor Author

oToToT commented May 4, 2021

I'm not very sure that whether /proc/[PID]/cmdline will always contain '\0' in the end or not. Might it be much better to append a '\0' directly to the end of the buffer?

@Syllo
Copy link
Owner

Syllo commented May 4, 2021

Hi,
Indeed, a zero character read can be returned for this file.
Could you please check that the fix in the branch cmdline_fix resolves this issue?

@oToToT
Copy link
Contributor Author

oToToT commented May 4, 2021

Hi,
Indeed, a zero character read can be returned for this file.
Could you please check that the fix in the branch cmdline_fix resolves this issue?

Yes, that patch do resolve this issue and I think it's a better fix than mine.

@Syllo
Copy link
Owner

Syllo commented May 4, 2021

Merged into master, you're welcome.
Take care!

@Syllo Syllo closed this May 4, 2021
@oToToT oToToT deleted the fix-empty-cmdline branch May 4, 2021 18:54
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.

2 participants