[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20180109173620.GS13726@twin.jikos.cz>
Date: Tue, 9 Jan 2018 18:36:20 +0100
From: David Sterba <dsterba@...e.cz>
To: Xiongfeng Wang <wangxiongfeng2@...wei.com>
Cc: dsterba@...e.com, clm@...com, jbacik@...com,
linux-btrfs@...r.kernel.org, linux-kernel@...r.kernel.org,
arnd@...db.de
Subject: Re: [PATCH] btrfs: use correct string length
On Mon, Jan 08, 2018 at 07:51:22PM +0800, Xiongfeng Wang wrote:
> From: Xiongfeng Wang <xiongfeng.wang@...aro.org>
>
> gcc-8 reports
>
> fs/btrfs/ioctl.c: In function 'btrfs_ioctl':
> ./include/linux/string.h:245:9: warning: '__builtin_strncpy' specified
> bound 1024 equals destination size [-Wstringop-truncation]
>
> We need one less byte or call strlcpy() to make it a nul-terminated
> string.
The null termination is on the following line, so this patch fixes
namely the gcc warning:
> - strncpy(di_args->path, name->str, sizeof(di_args->path));
> + strncpy(di_args->path, name->str, sizeof(di_args->path) - 1);
> rcu_read_unlock();
> di_args->path[sizeof(di_args->path) - 1] = 0;
Reviewed-by: David Sterba <dsterba@...e.com>
Powered by blists - more mailing lists