diff options
author | Jim Meyering <meyering@redhat.com> | 2012-10-04 13:09:51 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-10-05 07:58:37 -0500 |
commit | 3eadc68ebd174f5bad51fe6e0bbcf6d6651c784c (patch) | |
tree | f6b2444ca55b96d1b75f9cd7b156508a647ca8e5 /os-posix.c | |
parent | 1044dc1118d9a90e2aa324047bea9c91c889e28f (diff) | |
download | qemu-3eadc68ebd174f5bad51fe6e0bbcf6d6651c784c.tar.gz qemu-3eadc68ebd174f5bad51fe6e0bbcf6d6651c784c.tar.bz2 qemu-3eadc68ebd174f5bad51fe6e0bbcf6d6651c784c.zip |
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>
Diffstat (limited to 'os-posix.c')
-rw-r--r-- | os-posix.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/os-posix.c b/os-posix.c index eabccb8fe0..f855abb09a 100644 --- a/os-posix.c +++ b/os-posix.c @@ -148,8 +148,7 @@ void os_set_proc_name(const char *s) char name[16]; if (!s) return; - 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)) { |