lkml.org 
[lkml]   [2014]   [Aug]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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@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



\
 
 \ /
  Last update: 2014-08-05 22:41    [W:0.036 / U:0.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site