From e9d4cf411f7582537ed0038d0f32a8743b75e58a Mon Sep 17 00:00:00 2001 From: Fabian Frederick Date: Wed, 8 Apr 2015 21:23:54 +0200 Subject: udf: improve error management in udf_CS0toUTF8() udf_CS0toUTF8() now returns -EINVAL on error. udf_load_pvoldesc() and udf_get_filename() do the same. Suggested-by: Jan Kara Signed-off-by: Fabian Frederick Signed-off-by: Jan Kara --- fs/udf/super.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'fs/udf/super.c') diff --git a/fs/udf/super.c b/fs/udf/super.c index 6299f341967b..c6a8f5f79443 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -927,17 +927,22 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block) #endif } - if (!udf_build_ustr(instr, pvoldesc->volIdent, 32)) - if (udf_CS0toUTF8(outstr, instr)) { - strncpy(UDF_SB(sb)->s_volume_ident, outstr->u_name, - outstr->u_len > 31 ? 31 : outstr->u_len); - udf_debug("volIdent[] = '%s'\n", - UDF_SB(sb)->s_volume_ident); - } + if (!udf_build_ustr(instr, pvoldesc->volIdent, 32)) { + ret = udf_CS0toUTF8(outstr, instr); + if (ret < 0) + goto out_bh; + + strncpy(UDF_SB(sb)->s_volume_ident, outstr->u_name, + outstr->u_len > 31 ? 31 : outstr->u_len); + udf_debug("volIdent[] = '%s'\n", UDF_SB(sb)->s_volume_ident); + } if (!udf_build_ustr(instr, pvoldesc->volSetIdent, 128)) - if (udf_CS0toUTF8(outstr, instr)) - udf_debug("volSetIdent[] = '%s'\n", outstr->u_name); + ret = udf_CS0toUTF8(outstr, instr); + if (ret < 0) + goto out_bh; + + udf_debug("volSetIdent[] = '%s'\n", outstr->u_name); ret = 0; out_bh: -- cgit v1.2.3 From 792352cb160e654f0b64182550ee702a790fe4d0 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 20 May 2015 11:13:15 +0300 Subject: udf: fix udf_load_pvoldesc() There are some missing braces here which means this function never succeeds. Fixes: e9d4cf411f75 ('udf: improve error management in udf_CS0toUTF8()') Signed-off-by: Dan Carpenter Signed-off-by: Jan Kara --- fs/udf/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'fs/udf/super.c') diff --git a/fs/udf/super.c b/fs/udf/super.c index c6a8f5f79443..b96f190bc567 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -937,12 +937,13 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block) udf_debug("volIdent[] = '%s'\n", UDF_SB(sb)->s_volume_ident); } - if (!udf_build_ustr(instr, pvoldesc->volSetIdent, 128)) + if (!udf_build_ustr(instr, pvoldesc->volSetIdent, 128)) { ret = udf_CS0toUTF8(outstr, instr); if (ret < 0) goto out_bh; udf_debug("volSetIdent[] = '%s'\n", outstr->u_name); + } ret = 0; out_bh: -- cgit v1.2.3