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>,
"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH] arch: tile: kernel: setup.c: Cleaning up missing null-terminate in conjunction with strncpy
Date: Fri, 1 Aug 2014 16:12:57 -0400 [thread overview]
Message-ID: <53DBF4C9.70604@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;
Thanks for the patch (this and the one for mpipe.c). In general I'd rather
check the argument length and return a suitable error rather than using
strlcpy or strncpy to cause a corrupted partial string result. I've done
this for the examples you pointed to (which I think is everything in arch/tile)
and I'll push those changes up.
--
Chris Metcalf, Tilera Corp.
http://www.tilera.com
next prev parent reply other threads:[~2014-08-01 20:13 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 [this message]
2014-08-05 20:12 ` Chris Metcalf
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=53DBF4C9.70604@tilera.com \
--to=cmetcalf@tilera.com \
--cc=davem@davemloft.net \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox