From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:57281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFz57-0004Ov-D5 for qemu-devel@nongnu.org; Mon, 17 Oct 2011 22:07:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RFz55-0000hG-Oc for qemu-devel@nongnu.org; Mon, 17 Oct 2011 22:07:05 -0400 Received: from mail-qw0-f45.google.com ([209.85.216.45]:54014) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFz55-0000h1-MR for qemu-devel@nongnu.org; Mon, 17 Oct 2011 22:07:03 -0400 Received: by qadb10 with SMTP id b10so76587qad.4 for ; Mon, 17 Oct 2011 19:07:03 -0700 (PDT) From: Trevor Saunders Date: Mon, 17 Oct 2011 22:06:32 -0400 Message-Id: <1318903592-4851-1-git-send-email-trev.saunders@gmail.com> Subject: [Qemu-devel] [PATCH] correctly null terminate the process name List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Trevor Saunders 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 --- 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