[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-trivial] [Qemu-devel] [PATCH] correctly null terminate the pro

From: Stefan Weil
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] correctly null terminate the process name
Date: Tue, 18 Oct 2011 06:19:08 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20110921 Thunderbird/3.1.15

Am 18.10.2011 04:06, schrieb 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<address@hidden>
  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)
-    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)) {

Reviewed-by: Stefan Weil <address@hidden>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]