From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SS6jS-0007g5-SV for qemu-devel@nongnu.org; Wed, 09 May 2012 09:15:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SS6jI-0001Vl-Vc for qemu-devel@nongnu.org; Wed, 09 May 2012 09:15:06 -0400 Received: from e28smtp04.in.ibm.com ([122.248.162.4]:35016) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SS6jF-0001Od-EX for qemu-devel@nongnu.org; Wed, 09 May 2012 09:14:56 -0400 Received: from /spool/local by e28smtp04.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 9 May 2012 18:38:51 +0530 Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay01.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q49D7uOn30802072 for ; Wed, 9 May 2012 18:38:02 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q49IbhLf014863 for ; Thu, 10 May 2012 04:37:43 +1000 From: "Aneesh Kumar K.V" In-Reply-To: <1336555446-20180-13-git-send-email-jim@meyering.net> References: <1336555446-20180-1-git-send-email-jim@meyering.net> <1336555446-20180-13-git-send-email-jim@meyering.net>User-Agent: Notmuch/0.11.1+346~g13d19c3 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) Date: Wed, 09 May 2012 18:37:50 +0530 Message-ID: <877gwlmrix.fsf@skywalker.in.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH 12/22] virtio-9p: avoid unwarranted use of strncpy List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jim Meyering , qemu-devel@nongnu.org Cc: Jim Meyering Jim Meyering writes: > From: Jim Meyering > > The use of strncpy in mp_user_listxattr is unnecessary, since we > know that the NUL-terminated source bytes fit in the destination > buffer. Use memcpy in place of strncpy. > > Signed-off-by: Jim Meyering May be this can be folded into the earlier patch ? Reviewed-by: Aneeseh Kumar K.V > --- > hw/9pfs/virtio-9p-xattr-user.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/hw/9pfs/virtio-9p-xattr-user.c b/hw/9pfs/virtio-9p-xattr-user.c > index 5044a3e..5bb6020 100644 > --- a/hw/9pfs/virtio-9p-xattr-user.c > +++ b/hw/9pfs/virtio-9p-xattr-user.c > @@ -61,7 +61,8 @@ static ssize_t mp_user_listxattr(FsContext *ctx, const char *path, > return -1; > } > > - strncpy(value, name, name_size); > + /* name_size includes the trailing NUL. */ > + memcpy(value, name, name_size); > return name_size; > } > > -- > 1.7.10.1.487.ga3935e6