@@ -119,9 +119,8 @@ static u16 *hfsplus_compose_lookup(u16 *p, u16 cc)
119119 return NULL ;
120120}
121121
122- int hfsplus_uni2asc (struct super_block * sb ,
123- const struct hfsplus_unistr * ustr ,
124- char * astr , int * len_p )
122+ static int hfsplus_uni2asc (struct super_block * sb , const struct hfsplus_unistr * ustr ,
123+ int max_len , char * astr , int * len_p )
125124{
126125 const hfsplus_unichr * ip ;
127126 struct nls_table * nls = HFSPLUS_SB (sb )-> nls ;
@@ -134,8 +133,8 @@ int hfsplus_uni2asc(struct super_block *sb,
134133 ip = ustr -> unicode ;
135134
136135 ustrlen = be16_to_cpu (ustr -> length );
137- if (ustrlen > HFSPLUS_MAX_STRLEN ) {
138- ustrlen = HFSPLUS_MAX_STRLEN ;
136+ if (ustrlen > max_len ) {
137+ ustrlen = max_len ;
139138 pr_err ("invalid length %u has been corrected to %d\n" ,
140139 be16_to_cpu (ustr -> length ), ustrlen );
141140 }
@@ -256,6 +255,21 @@ int hfsplus_uni2asc(struct super_block *sb,
256255 return res ;
257256}
258257
258+ inline int hfsplus_uni2asc_str (struct super_block * sb ,
259+ const struct hfsplus_unistr * ustr , char * astr ,
260+ int * len_p )
261+ {
262+ return hfsplus_uni2asc (sb , ustr , HFSPLUS_MAX_STRLEN , astr , len_p );
263+ }
264+
265+ inline int hfsplus_uni2asc_xattr_str (struct super_block * sb ,
266+ const struct hfsplus_attr_unistr * ustr ,
267+ char * astr , int * len_p )
268+ {
269+ return hfsplus_uni2asc (sb , (const struct hfsplus_unistr * )ustr ,
270+ HFSPLUS_ATTR_MAX_STRLEN , astr , len_p );
271+ }
272+
259273/*
260274 * Convert one or more ASCII characters into a single unicode character.
261275 * Returns the number of ASCII characters corresponding to the unicode char.
0 commit comments