mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-10-15 15:32:51 +00:00
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: Jim Meyering <meyering@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
1044dc1118
commit
3eadc68ebd
|
@ -148,8 +148,7 @@ void os_set_proc_name(const char *s)
|
||||||
char name[16];
|
char name[16];
|
||||||
if (!s)
|
if (!s)
|
||||||
return;
|
return;
|
||||||
name[sizeof(name) - 1] = 0;
|
pstrcpy(name, sizeof(name), s);
|
||||||
strncpy(name, s, sizeof(name));
|
|
||||||
/* Could rewrite argv[0] too, but that's a bit more complicated.
|
/* Could rewrite argv[0] too, but that's a bit more complicated.
|
||||||
This simple way is enough for `top'. */
|
This simple way is enough for `top'. */
|
||||||
if (prctl(PR_SET_NAME, name)) {
|
if (prctl(PR_SET_NAME, name)) {
|
||||||
|
|
Loading…
Reference in a new issue