Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753075Ab1DUHAR (ORCPT ); Thu, 21 Apr 2011 03:00:17 -0400 Received: from mail-qy0-f174.google.com ([209.85.216.174]:62095 "EHLO mail-qy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750704Ab1DUHAP convert rfc822-to-8bit (ORCPT ); Thu, 21 Apr 2011 03:00:15 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; b=icfYUz7ui9xR83AqwLV8wGsrosGkLODkC6r7KrCBTb9RDaBiGpqATNk1S1Fo/zqy8p KQWjKYZ27ooP/OZ0vRAgl+vyHMY5VuKDJBITcyDC1YTIK44fHbllOTCvkLShIgd5xOt7 foQVYWq4dtpTt8Uy02xXy+hW9y3qdTgn/SUeU= MIME-Version: 1.0 In-Reply-To: <87tydtm41s.fsf@tucsk.pomaz.szeredi.hu> References: <4DA4B6A8.7030804@gmail.com> <87tydu3t4p.fsf_-_@tucsk.pomaz.szeredi.hu> <87tydtm41s.fsf@tucsk.pomaz.szeredi.hu> From: Michal Suchanek Date: Thu, 21 Apr 2011 08:59:54 +0200 X-Google-Sender-Auth: LcYIRXI8kbqD9LbMoxiscOIq5wc Message-ID: Subject: Re: [PATCH] tmpfs: implement generic xattr support To: Miklos Szeredi Cc: Phillip Lougher , Andreas Dilger , Jiri Kosina , Ric Wheeler , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, David Howells , Ian Kent , Jeff Moyer , Christoph Hellwig , Hugh Dickins , Eric Paris Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1979 Lines: 46 On 20 April 2011 15:43, Miklos Szeredi wrote: > Phillip Lougher writes: > >> On Tue, Apr 19, 2011 at 9:04 PM, Miklos Szeredi wrote: >> >>> +static ssize_t shmem_listxattr(struct dentry *dentry, char *buffer, size_t size) >> >>> +       spin_lock(&dentry->d_inode->i_lock); >>> +       list_for_each_entry(xattr, &info->xattr_list, list) { >>> +               /* skip "trusted." attributes for unprivileged callers */ >>> +               if (!trusted && xattr_is_trusted(xattr->name)) >>> +                       continue; >>> + >>> +               used += strlen(xattr->name) + 1; >>> +               if (buffer) { >>> +                       if (size < used) { >>> +                               used = -ERANGE; >>> +                               break; >>> +                       } >>> +                       strncpy(buffer, xattr->name, strlen(xattr->name) + 1); >>>+                        buffer += strlen(xattr->name) + 1; >> >> Why are you doing a strncpy here?  strcpy() isn't going to copy more >> than strlen(xattr->name) + 1 bytes, and you know buffer is large >> enough to hold that because of the previous if (size < used) check? >> >> If you assigned the first strlen(xattr->name) + 1 to a temporary >> variable, you could use memcpy here, and avoid the 3 repeated >> strlen(xattr->name) calls. > > Yeah, makes sense. > Can you put up a branch with both overlayfs and xattrs? I would like to point people at a repo with working implementation and mirroring the kernel tree to add one patch is a bit overkill. Thanks Michal -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/