Commit 3eadc68e authored by Jim Meyering's avatar Jim Meyering Committed by Anthony Liguori

os-posix: avoid buffer overrun

os_set_proc_name: Use pstrcpy, in place of strncpy and the
ineffectual preceding assignment: name[sizeof(name) - 1] = 0;
Signed-off-by: default avatarJim Meyering <>
Signed-off-by: default avatarAnthony Liguori <>
parent 1044dc11
......@@ -148,8 +148,7 @@ void os_set_proc_name(const char *s)
char name[16];
if (!s)
name[sizeof(name) - 1] = 0;
strncpy(name, s, sizeof(name));
pstrcpy(name, sizeof(name), s);
/* Could rewrite argv[0] too, but that's a bit more complicated.
This simple way is enough for `top'. */
if (prctl(PR_SET_NAME, name)) {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment