diff options
Diffstat (limited to 'fs/hfsplus/attributes.c')
-rw-r--r-- | fs/hfsplus/attributes.c | 36 |
1 files changed, 4 insertions, 32 deletions
diff --git a/fs/hfsplus/attributes.c b/fs/hfsplus/attributes.c index caf89a7be0a1..e5b221de7de6 100644 --- a/fs/hfsplus/attributes.c +++ b/fs/hfsplus/attributes.c | |||
@@ -54,14 +54,11 @@ int hfsplus_attr_build_key(struct super_block *sb, hfsplus_btree_key *key, | |||
54 | memset(key, 0, sizeof(struct hfsplus_attr_key)); | 54 | memset(key, 0, sizeof(struct hfsplus_attr_key)); |
55 | key->attr.cnid = cpu_to_be32(cnid); | 55 | key->attr.cnid = cpu_to_be32(cnid); |
56 | if (name) { | 56 | if (name) { |
57 | len = strlen(name); | 57 | int res = hfsplus_asc2uni(sb, |
58 | if (len > HFSPLUS_ATTR_MAX_STRLEN) { | ||
59 | pr_err("invalid xattr name's length\n"); | ||
60 | return -EINVAL; | ||
61 | } | ||
62 | hfsplus_asc2uni(sb, | ||
63 | (struct hfsplus_unistr *)&key->attr.key_name, | 58 | (struct hfsplus_unistr *)&key->attr.key_name, |
64 | HFSPLUS_ATTR_MAX_STRLEN, name, len); | 59 | HFSPLUS_ATTR_MAX_STRLEN, name, strlen(name)); |
60 | if (res) | ||
61 | return res; | ||
65 | len = be16_to_cpu(key->attr.key_name.length); | 62 | len = be16_to_cpu(key->attr.key_name.length); |
66 | } else { | 63 | } else { |
67 | key->attr.key_name.length = 0; | 64 | key->attr.key_name.length = 0; |
@@ -82,31 +79,6 @@ int hfsplus_attr_build_key(struct super_block *sb, hfsplus_btree_key *key, | |||
82 | return 0; | 79 | return 0; |
83 | } | 80 | } |
84 | 81 | ||
85 | void hfsplus_attr_build_key_uni(hfsplus_btree_key *key, | ||
86 | u32 cnid, | ||
87 | struct hfsplus_attr_unistr *name) | ||
88 | { | ||
89 | int ustrlen; | ||
90 | |||
91 | memset(key, 0, sizeof(struct hfsplus_attr_key)); | ||
92 | ustrlen = be16_to_cpu(name->length); | ||
93 | key->attr.cnid = cpu_to_be32(cnid); | ||
94 | key->attr.key_name.length = cpu_to_be16(ustrlen); | ||
95 | ustrlen *= 2; | ||
96 | memcpy(key->attr.key_name.unicode, name->unicode, ustrlen); | ||
97 | |||
98 | /* The length of the key, as stored in key_len field, does not include | ||
99 | * the size of the key_len field itself. | ||
100 | * So, offsetof(hfsplus_attr_key, key_name) is a trick because | ||
101 | * it takes into consideration key_len field (__be16) of | ||
102 | * hfsplus_attr_key structure instead of length field (__be16) of | ||
103 | * hfsplus_attr_unistr structure. | ||
104 | */ | ||
105 | key->key_len = | ||
106 | cpu_to_be16(offsetof(struct hfsplus_attr_key, key_name) + | ||
107 | ustrlen); | ||
108 | } | ||
109 | |||
110 | hfsplus_attr_entry *hfsplus_alloc_attr_entry(void) | 82 | hfsplus_attr_entry *hfsplus_alloc_attr_entry(void) |
111 | { | 83 | { |
112 | return kmem_cache_alloc(hfsplus_attr_tree_cachep, GFP_KERNEL); | 84 | return kmem_cache_alloc(hfsplus_attr_tree_cachep, GFP_KERNEL); |