linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Cc: dsterba@suse.com, clm@fb.com, jbacik@fb.com,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	arnd@arndb.de
Subject: Re: [PATCH] btrfs: use correct string length
Date: Tue, 9 Jan 2018 18:36:20 +0100	[thread overview]
Message-ID: <20180109173620.GS13726@twin.jikos.cz> (raw)
In-Reply-To: <1515412282-57381-1-git-send-email-wangxiongfeng2@huawei.com>

On Mon, Jan 08, 2018 at 07:51:22PM +0800, Xiongfeng Wang wrote:
> From: Xiongfeng Wang <xiongfeng.wang@linaro.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@suse.com>


      reply	other threads:[~2018-01-09 17:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-08 11:51 [PATCH] btrfs: use correct string length Xiongfeng Wang
2018-01-09 17:36 ` David Sterba [this message]

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=20180109173620.GS13726@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=arnd@arndb.de \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=jbacik@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wangxiongfeng2@huawei.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;
as well as URLs for NNTP newsgroup(s).