aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/udf/udfdecl.h2
-rw-r--r--fs/udf/unicode.c27
2 files changed, 11 insertions, 18 deletions
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index d3aae5633722..2310b5c8fd8b 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -175,7 +175,7 @@ extern int udf_get_filename(struct super_block *, uint8_t *, uint8_t *, int);
175extern int udf_put_filename(struct super_block *, const uint8_t *, uint8_t *, 175extern int udf_put_filename(struct super_block *, const uint8_t *, uint8_t *,
176 int); 176 int);
177extern int udf_build_ustr(struct ustr *, dstring *, int); 177extern int udf_build_ustr(struct ustr *, dstring *, int);
178extern int udf_CS0toUTF8(struct ustr *, struct ustr *); 178extern int udf_CS0toUTF8(struct ustr *, const struct ustr *);
179 179
180/* ialloc.c */ 180/* ialloc.c */
181extern void udf_free_inode(struct inode *); 181extern void udf_free_inode(struct inode *);
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index b9de050ad830..05bc505ec01a 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -82,9 +82,6 @@ static int udf_build_ustr_exact(struct ustr *dest, dstring *ptr, int exactsize)
82 * PURPOSE 82 * PURPOSE
83 * Convert OSTA Compressed Unicode to the UTF-8 equivalent. 83 * Convert OSTA Compressed Unicode to the UTF-8 equivalent.
84 * 84 *
85 * DESCRIPTION
86 * This routine is only called by udf_filldir().
87 *
88 * PRE-CONDITIONS 85 * PRE-CONDITIONS
89 * utf Pointer to UTF-8 output buffer. 86 * utf Pointer to UTF-8 output buffer.
90 * ocu Pointer to OSTA Compressed Unicode input buffer 87 * ocu Pointer to OSTA Compressed Unicode input buffer
@@ -98,43 +95,39 @@ static int udf_build_ustr_exact(struct ustr *dest, dstring *ptr, int exactsize)
98 * November 12, 1997 - Andrew E. Mileski 95 * November 12, 1997 - Andrew E. Mileski
99 * Written, tested, and released. 96 * Written, tested, and released.
100 */ 97 */
101int udf_CS0toUTF8(struct ustr *utf_o, struct ustr *ocu_i) 98int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i)
102{ 99{
103 uint8_t *ocu; 100 const uint8_t *ocu;
104 uint32_t c;
105 uint8_t cmp_id, ocu_len; 101 uint8_t cmp_id, ocu_len;
106 int i; 102 int i;
107 103
108 ocu = ocu_i->u_name;
109
110 ocu_len = ocu_i->u_len; 104 ocu_len = ocu_i->u_len;
111 cmp_id = ocu_i->u_cmpID;
112 utf_o->u_len = 0;
113
114 if (ocu_len == 0) { 105 if (ocu_len == 0) {
115 memset(utf_o, 0, sizeof(struct ustr)); 106 memset(utf_o, 0, sizeof(struct ustr));
116 utf_o->u_cmpID = 0;
117 utf_o->u_len = 0;
118 return 0; 107 return 0;
119 } 108 }
120 109
121 if ((cmp_id != 8) && (cmp_id != 16)) { 110 cmp_id = ocu_i->u_cmpID;
111 if (cmp_id != 8 && cmp_id != 16) {
112 memset(utf_o, 0, sizeof(struct ustr));
122 printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n", 113 printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n",
123 cmp_id, ocu_i->u_name); 114 cmp_id, ocu_i->u_name);
124 return 0; 115 return 0;
125 } 116 }
126 117
118 ocu = ocu_i->u_name;
119 utf_o->u_len = 0;
127 for (i = 0; (i < ocu_len) && (utf_o->u_len <= (UDF_NAME_LEN - 3));) { 120 for (i = 0; (i < ocu_len) && (utf_o->u_len <= (UDF_NAME_LEN - 3));) {
128 121
129 /* Expand OSTA compressed Unicode to Unicode */ 122 /* Expand OSTA compressed Unicode to Unicode */
130 c = ocu[i++]; 123 uint32_t c = ocu[i++];
131 if (cmp_id == 16) 124 if (cmp_id == 16)
132 c = (c << 8) | ocu[i++]; 125 c = (c << 8) | ocu[i++];
133 126
134 /* Compress Unicode to UTF-8 */ 127 /* Compress Unicode to UTF-8 */
135 if (c < 0x80U) { 128 if (c < 0x80U)
136 utf_o->u_name[utf_o->u_len++] = (uint8_t)c; 129 utf_o->u_name[utf_o->u_len++] = (uint8_t)c;
137 } else if (c < 0x800U) { 130 else if (c < 0x800U) {
138 utf_o->u_name[utf_o->u_len++] = 131 utf_o->u_name[utf_o->u_len++] =
139 (uint8_t)(0xc0 | (c >> 6)); 132 (uint8_t)(0xc0 | (c >> 6));
140 utf_o->u_name[utf_o->u_len++] = 133 utf_o->u_name[utf_o->u_len++] =