From: "Pádraig Brady" <P@draigBrady.com>
To: Roel Kluin <roel.kluin@gmail.com>
Cc: Randy Dunlap <rdunlap@xenotime.net>,
linux-doc@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>,
David Wagner <daw@cs.berkeley.edu>
Subject: Re: [PATCH] Documentation: Fix NUL termination of strncpy
Date: Tue, 17 Nov 2009 12:25:03 +0000 [thread overview]
Message-ID: <4B02961F.8020108@draigBrady.com> (raw)
In-Reply-To: <4B019F52.50509@gmail.com>
Roel Kluin wrote:
> Ensure the copied strings are NUL terminated.
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
>> Rationale (please correct me if I'm wrong):
>
> diff --git a/Documentation/accounting/getdelays.c b/Documentation/accounting/getdelays.c
> index 6e25c26..4d71b0e 100644
> --- a/Documentation/accounting/getdelays.c
> +++ b/Documentation/accounting/getdelays.c
> @@ -303,7 +303,7 @@ int main(int argc, char *argv[])
> err(1, "Invalid rcv buf size\n");
> break;
> case 'm':
> - strncpy(cpumask, optarg, sizeof(cpumask));
> + strncpy(cpumask, optarg, sizeof(cpumask) - 1);
You need to explicitly NUL terminate strncpy():
http://www.pixelbeat.org/programming/gcc/string_buffers.html
cheers,
Pádraig.
next prev parent reply other threads:[~2009-11-17 12:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-16 16:55 [PATCH] Documentation: Fix NUL termination of strncpy Roel Kluin
2009-11-16 18:52 ` Roel Kluin
2009-11-16 21:24 ` Roel Kluin
2009-11-17 12:25 ` Pádraig Brady [this message]
2009-11-17 16:41 ` Valdis.Kletnieks
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=4B02961F.8020108@draigBrady.com \
--to=p@draigbrady.com \
--cc=akpm@linux-foundation.org \
--cc=daw@cs.berkeley.edu \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rdunlap@xenotime.net \
--cc=roel.kluin@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.