Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934542AbeAIRib (ORCPT + 1 other); Tue, 9 Jan 2018 12:38:31 -0500 Received: from mx2.suse.de ([195.135.220.15]:49436 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751647AbeAIRi3 (ORCPT ); Tue, 9 Jan 2018 12:38:29 -0500 Date: Tue, 9 Jan 2018 18:36:20 +0100 From: David Sterba To: Xiongfeng Wang 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 Message-ID: <20180109173620.GS13726@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Xiongfeng Wang , dsterba@suse.com, clm@fb.com, jbacik@fb.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, arnd@arndb.de References: <1515412282-57381-1-git-send-email-wangxiongfeng2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1515412282-57381-1-git-send-email-wangxiongfeng2@huawei.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Mon, Jan 08, 2018 at 07:51:22PM +0800, Xiongfeng Wang wrote: > From: Xiongfeng Wang > > 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