[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Tue, 3 Mar 2015 19:04:25 +0100 (CET)
From: Fabian Frederick <fabf@...net.be>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2 linux-next] FS/HFSPLUS: move xattr_name allocation
in hfsplus_setxattr()
> On 02 March 2015 at 23:25 Andrew Morton <akpm@...ux-foundation.org> wrote:
>
>
> On Fri, 27 Feb 2015 18:38:26 +0100 Fabian Frederick <fabf@...net.be> wrote:
>
> > security/trusted/user/osx setxattr did the same
> > xattr_name initialization. Move that operation in hfsplus_setxattr().
> >
> > Tested with security/trusted/user getfattr/setfattr
> >
> > --- a/fs/hfsplus/xattr.c
> > +++ b/fs/hfsplus/xattr.c
> > @@ -424,6 +424,28 @@ static int copy_name(char *buffer, const char
> > *xattr_name, int name_len)
> > return len;
> > }
> >
> > +int hfsplus_setxattr(struct dentry *dentry, const char *name,
> > + const void *value, size_t size, int flags,
> > + const char *prefix, size_t prefixlen)
> > +{
> > + char *xattr_name;
> > + int res;
> > +
> > + if (!strcmp(name, ""))
> > + return -EINVAL;
> > +
> > + xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN + 1,
> > + GFP_KERNEL);
> > + if (!xattr_name)
> > + return -ENOMEM;
> > + strcpy(xattr_name, prefix);
> > + strcpy(xattr_name + prefixlen, name);
>
> Can we use kasprintf(GFP_KERNEL, "%s%s", prefix, name) and zap `prefixlen'?
Of course :) Thanks Andrew, I'll send a small patchset for relevant filesystems.
Regards,
Fabian
>
> > + res = __hfsplus_setxattr(dentry->d_inode, xattr_name, value, size,
> > + flags);
> > + kfree(xattr_name);
> > + return res;
> > +}
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists