From: Trevor Saunders <trev.saunders@gmail.com>
To: qemu-devel@nongnu.org
Cc: Trevor Saunders <trev.saunders@gmail.com>
Subject: [Qemu-devel] [PATCH] correctly null terminate the process name
Date: Mon, 17 Oct 2011 22:06:32 -0400 [thread overview]
Message-ID: <1318903592-4851-1-git-send-email-trev.saunders@gmail.com> (raw)
strncpy() doesn't garentee the copied string will be null terminated if
the original is longer than the length to copy.
Signed-off-by: Trevor Saunders <trev.saunders@gmail.com>
---
os-posix.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/os-posix.c b/os-posix.c
index dbf3b24..92dcc97 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -149,8 +149,8 @@ void os_set_proc_name(const char *s)
char name[16];
if (!s)
return;
- name[sizeof(name) - 1] = 0;
strncpy(name, s, sizeof(name));
+ name[sizeof(name) - 1] = 0;
/* 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)) {
--
1.7.7
next reply other threads:[~2011-10-18 2:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-18 2:06 Trevor Saunders [this message]
2011-10-18 4:19 ` [Qemu-devel] [PATCH] correctly null terminate the process name Stefan Weil
2011-10-18 5:06 ` malc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1318903592-4851-1-git-send-email-trev.saunders@gmail.com \
--to=trev.saunders@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).