From: Chris Metcalf <cmetcalf@tilera.com>
To: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>,
Wang Sheng-Hui <shhuiw@gmail.com>
Cc: Daniel Walter <dwalter@google.com>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] arch: tile: kernel: setup.c: Cleaning up missing null-terminate in conjunction with strncpy
Date: Tue, 5 Aug 2014 16:12:55 -0400 [thread overview]
Message-ID: <53E13AC7.1030406@tilera.com> (raw)
In-Reply-To: <1406383480-1485-1-git-send-email-rickard_strandqvist@spectrumdigital.se>
On 7/26/2014 10:04 AM, Rickard Strandqvist wrote:
> Replacing strncpy with strlcpy to avoid strings that lacks null terminate.
>
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
> arch/tile/kernel/setup.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/tile/kernel/setup.c b/arch/tile/kernel/setup.c
> index 112abab..1af7d19 100644
> --- a/arch/tile/kernel/setup.c
> +++ b/arch/tile/kernel/setup.c
> @@ -1087,7 +1087,7 @@ static int __init setup_initramfs_file(char *str)
> {
> if (str == NULL)
> return -EINVAL;
> - strncpy(initramfs_file, str, sizeof(initramfs_file) - 1);
> + strlcpy(initramfs_file, str, sizeof(initramfs_file));
> set_initramfs_file = 1;
>
> return 0;
I'm inclined not to take this change, because it's not necessary.
The initramfs_file[] is already zero-filled by being in the BSS, and
this is a pretty obscure boot option, so it seems a bit more
maintainable to use a somewhat more standard string API call.
--
Chris Metcalf, Tilera Corp.
http://www.tilera.com
next prev parent reply other threads:[~2014-08-05 20:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-26 14:04 [PATCH] arch: tile: kernel: setup.c: Cleaning up missing null-terminate in conjunction with strncpy Rickard Strandqvist
2014-08-01 20:12 ` Chris Metcalf
2014-08-05 20:12 ` Chris Metcalf [this message]
2014-08-05 20:40 ` Rickard Strandqvist
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=53E13AC7.1030406@tilera.com \
--to=cmetcalf@tilera.com \
--cc=dwalter@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rickard_strandqvist@spectrumdigital.se \
--cc=shhuiw@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.