All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Weil <sw@weilnetz.de>
To: Trevor Saunders <trev.saunders@gmail.com>
Cc: qemu-trivial <qemu-trivial@nongnu.org>,
	Jes Sorensen <Jes.Sorensen@redhat.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] correctly null terminate the process name
Date: Tue, 18 Oct 2011 06:19:08 +0200	[thread overview]
Message-ID: <4E9CFE3C.80205@weilnetz.de> (raw)
In-Reply-To: <1318903592-4851-1-git-send-email-trev.saunders@gmail.com>

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<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)) {

Reviewed-by: Stefan Weil <sw@weilnetz.de>



WARNING: multiple messages have this Message-ID (diff)
From: Stefan Weil <sw@weilnetz.de>
To: Trevor Saunders <trev.saunders@gmail.com>
Cc: qemu-trivial <qemu-trivial@nongnu.org>,
	Jes Sorensen <Jes.Sorensen@redhat.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] correctly null terminate the process name
Date: Tue, 18 Oct 2011 06:19:08 +0200	[thread overview]
Message-ID: <4E9CFE3C.80205@weilnetz.de> (raw)
In-Reply-To: <1318903592-4851-1-git-send-email-trev.saunders@gmail.com>

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<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)) {

Reviewed-by: Stefan Weil <sw@weilnetz.de>

  reply	other threads:[~2011-10-18  4:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-18  2:06 [Qemu-devel] [PATCH] correctly null terminate the process name Trevor Saunders
2011-10-18  4:19 ` Stefan Weil [this message]
2011-10-18  4:19   ` Stefan Weil
2011-10-18  5:06   ` [Qemu-trivial] " malc
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=4E9CFE3C.80205@weilnetz.de \
    --to=sw@weilnetz.de \
    --cc=Jes.Sorensen@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=trev.saunders@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.