[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <53DBF4C9.70604@tilera.com>
Date: Fri, 1 Aug 2014 16:12:57 -0400
From: Chris Metcalf <cmetcalf@...era.com>
To: Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>,
Wang Sheng-Hui <shhuiw@...il.com>
CC: Daniel Walter <dwalter@...gle.com>, <linux-kernel@...r.kernel.org>,
"David S. Miller" <davem@...emloft.net>
Subject: Re: [PATCH] arch: tile: kernel: setup.c: Cleaning up missing null-terminate
in conjunction with strncpy
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@...ctrumdigital.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists