Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pspax: rework & document get_proc_name
The current scanf format tries to use "%s.16" to limit reading to 16 bytes, but that doesn't actually work -- the maximum field width is between the "%" and the "s", so it should have been "%16s". This ends up working anyways because the %s consumes the entire string before it stops, and then scanf stops processing after it can't match ".16". If the size of the field were BUFSIZE or larger, then it'd overflow. In practice, BUFSIZ tends to be "large" (i.e. O(KiB)), and the kernel will truncate this field to 16 bytes for userspace programs. Kernel threads can have longer names, but not that big. At least, on Linux. Fix the scanf string to properly limit to 15 bytes, and change the local buffer to be exactly 16 bytes rather than the unrelated BUFSIZ (which is a stdio.h buffer size, and nothing related to kernel processes). Then add some more comments to explain what the code is actually doing, and simplify the final NUL logic to avoid redundant work. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
- Loading branch information