Skip to content

Commit 33656a1

Browse files
committed
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
Pull UDF fix from Jan Kara: "A fix of a regression in UDF that got introduced in 4.6-rc1 by one of the charset encoding fixes" * 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: udf: Fix conversion of 'dstring' fields to UTF8
2 parents 5f40adb + c26f6c6 commit 33656a1

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

fs/udf/super.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,14 +919,14 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
919919
#endif
920920
}
921921

922-
ret = udf_CS0toUTF8(outstr, 31, pvoldesc->volIdent, 32);
922+
ret = udf_dstrCS0toUTF8(outstr, 31, pvoldesc->volIdent, 32);
923923
if (ret < 0)
924924
goto out_bh;
925925

926926
strncpy(UDF_SB(sb)->s_volume_ident, outstr, ret);
927927
udf_debug("volIdent[] = '%s'\n", UDF_SB(sb)->s_volume_ident);
928928

929-
ret = udf_CS0toUTF8(outstr, 127, pvoldesc->volSetIdent, 128);
929+
ret = udf_dstrCS0toUTF8(outstr, 127, pvoldesc->volSetIdent, 128);
930930
if (ret < 0)
931931
goto out_bh;
932932

fs/udf/udfdecl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ extern int udf_get_filename(struct super_block *, const uint8_t *, int,
212212
uint8_t *, int);
213213
extern int udf_put_filename(struct super_block *, const uint8_t *, int,
214214
uint8_t *, int);
215-
extern int udf_CS0toUTF8(uint8_t *, int, const uint8_t *, int);
215+
extern int udf_dstrCS0toUTF8(uint8_t *, int, const uint8_t *, int);
216216

217217
/* ialloc.c */
218218
extern void udf_free_inode(struct inode *);

fs/udf/unicode.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,21 @@ static int udf_name_to_CS0(uint8_t *ocu, int ocu_max_len,
335335
return u_len;
336336
}
337337

338-
int udf_CS0toUTF8(uint8_t *utf_o, int o_len, const uint8_t *ocu_i, int i_len)
338+
int udf_dstrCS0toUTF8(uint8_t *utf_o, int o_len,
339+
const uint8_t *ocu_i, int i_len)
339340
{
340-
return udf_name_from_CS0(utf_o, o_len, ocu_i, i_len,
341+
int s_len = 0;
342+
343+
if (i_len > 0) {
344+
s_len = ocu_i[i_len - 1];
345+
if (s_len >= i_len) {
346+
pr_err("incorrect dstring lengths (%d/%d)\n",
347+
s_len, i_len);
348+
return -EINVAL;
349+
}
350+
}
351+
352+
return udf_name_from_CS0(utf_o, o_len, ocu_i, s_len,
341353
udf_uni2char_utf8, 0);
342354
}
343355

0 commit comments

Comments
 (0)