aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hfsplus/xattr_trusted.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/hfsplus/xattr_trusted.c')
-rw-r--r--fs/hfsplus/xattr_trusted.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/fs/hfsplus/xattr_trusted.c b/fs/hfsplus/xattr_trusted.c
index 426cee277542..3c5f27e4746a 100644
--- a/fs/hfsplus/xattr_trusted.c
+++ b/fs/hfsplus/xattr_trusted.c
@@ -6,43 +6,51 @@
6 * Handler for trusted extended attributes. 6 * Handler for trusted extended attributes.
7 */ 7 */
8 8
9#include <linux/nls.h>
10
9#include "hfsplus_fs.h" 11#include "hfsplus_fs.h"
10#include "xattr.h" 12#include "xattr.h"
11 13
12static int hfsplus_trusted_getxattr(struct dentry *dentry, const char *name, 14static int hfsplus_trusted_getxattr(struct dentry *dentry, const char *name,
13 void *buffer, size_t size, int type) 15 void *buffer, size_t size, int type)
14{ 16{
15 char xattr_name[HFSPLUS_ATTR_MAX_STRLEN + 1] = {0}; 17 char *xattr_name;
16 size_t len = strlen(name); 18 int res;
17 19
18 if (!strcmp(name, "")) 20 if (!strcmp(name, ""))
19 return -EINVAL; 21 return -EINVAL;
20 22
21 if (len + XATTR_TRUSTED_PREFIX_LEN > HFSPLUS_ATTR_MAX_STRLEN) 23 xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN + 1,
22 return -EOPNOTSUPP; 24 GFP_KERNEL);
23 25 if (!xattr_name)
26 return -ENOMEM;
24 strcpy(xattr_name, XATTR_TRUSTED_PREFIX); 27 strcpy(xattr_name, XATTR_TRUSTED_PREFIX);
25 strcpy(xattr_name + XATTR_TRUSTED_PREFIX_LEN, name); 28 strcpy(xattr_name + XATTR_TRUSTED_PREFIX_LEN, name);
26 29
27 return hfsplus_getxattr(dentry, xattr_name, buffer, size); 30 res = hfsplus_getxattr(dentry, xattr_name, buffer, size);
31 kfree(xattr_name);
32 return res;
28} 33}
29 34
30static int hfsplus_trusted_setxattr(struct dentry *dentry, const char *name, 35static int hfsplus_trusted_setxattr(struct dentry *dentry, const char *name,
31 const void *buffer, size_t size, int flags, int type) 36 const void *buffer, size_t size, int flags, int type)
32{ 37{
33 char xattr_name[HFSPLUS_ATTR_MAX_STRLEN + 1] = {0}; 38 char *xattr_name;
34 size_t len = strlen(name); 39 int res;
35 40
36 if (!strcmp(name, "")) 41 if (!strcmp(name, ""))
37 return -EINVAL; 42 return -EINVAL;
38 43
39 if (len + XATTR_TRUSTED_PREFIX_LEN > HFSPLUS_ATTR_MAX_STRLEN) 44 xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN + 1,
40 return -EOPNOTSUPP; 45 GFP_KERNEL);
41 46 if (!xattr_name)
47 return -ENOMEM;
42 strcpy(xattr_name, XATTR_TRUSTED_PREFIX); 48 strcpy(xattr_name, XATTR_TRUSTED_PREFIX);
43 strcpy(xattr_name + XATTR_TRUSTED_PREFIX_LEN, name); 49 strcpy(xattr_name + XATTR_TRUSTED_PREFIX_LEN, name);
44 50
45 return hfsplus_setxattr(dentry, xattr_name, buffer, size, flags); 51 res = hfsplus_setxattr(dentry, xattr_name, buffer, size, flags);
52 kfree(xattr_name);
53 return res;
46} 54}
47 55
48static size_t hfsplus_trusted_listxattr(struct dentry *dentry, char *list, 56static size_t hfsplus_trusted_listxattr(struct dentry *dentry, char *list,