Closed oToToT closed 3 years ago
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?
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?
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.
Merged into master, you're welcome. Take care!
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
.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.