diff options
author | Fabian Frederick <fabf@skynet.be> | 2015-04-08 15:23:54 -0400 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2015-05-18 05:23:05 -0400 |
commit | e9d4cf411f7582537ed0038d0f32a8743b75e58a (patch) | |
tree | cce973fd1e174661934c3d691ac0280e231c7907 /fs/udf | |
parent | d67e4a481425106a43c8d3cef82a82cc31b4edd8 (diff) |
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 <jack@suse.cz>
Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf')
-rw-r--r-- | fs/udf/super.c | 23 | ||||
-rw-r--r-- | fs/udf/unicode.c | 7 |
2 files changed, 18 insertions, 12 deletions
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) | |||
927 | #endif | 927 | #endif |
928 | } | 928 | } |
929 | 929 | ||
930 | if (!udf_build_ustr(instr, pvoldesc->volIdent, 32)) | 930 | if (!udf_build_ustr(instr, pvoldesc->volIdent, 32)) { |
931 | if (udf_CS0toUTF8(outstr, instr)) { | 931 | ret = udf_CS0toUTF8(outstr, instr); |
932 | strncpy(UDF_SB(sb)->s_volume_ident, outstr->u_name, | 932 | if (ret < 0) |
933 | outstr->u_len > 31 ? 31 : outstr->u_len); | 933 | goto out_bh; |
934 | udf_debug("volIdent[] = '%s'\n", | 934 | |
935 | UDF_SB(sb)->s_volume_ident); | 935 | strncpy(UDF_SB(sb)->s_volume_ident, outstr->u_name, |
936 | } | 936 | outstr->u_len > 31 ? 31 : outstr->u_len); |
937 | udf_debug("volIdent[] = '%s'\n", UDF_SB(sb)->s_volume_ident); | ||
938 | } | ||
937 | 939 | ||
938 | if (!udf_build_ustr(instr, pvoldesc->volSetIdent, 128)) | 940 | if (!udf_build_ustr(instr, pvoldesc->volSetIdent, 128)) |
939 | if (udf_CS0toUTF8(outstr, instr)) | 941 | ret = udf_CS0toUTF8(outstr, instr); |
940 | udf_debug("volSetIdent[] = '%s'\n", outstr->u_name); | 942 | if (ret < 0) |
943 | goto out_bh; | ||
944 | |||
945 | udf_debug("volSetIdent[] = '%s'\n", outstr->u_name); | ||
941 | 946 | ||
942 | ret = 0; | 947 | ret = 0; |
943 | out_bh: | 948 | out_bh: |
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c index 41c3bef1d226..35cc9477b066 100644 --- a/fs/udf/unicode.c +++ b/fs/udf/unicode.c | |||
@@ -89,7 +89,7 @@ static void udf_build_ustr_exact(struct ustr *dest, dstring *ptr, int exactsize) | |||
89 | * both of type "struct ustr *" | 89 | * both of type "struct ustr *" |
90 | * | 90 | * |
91 | * POST-CONDITIONS | 91 | * POST-CONDITIONS |
92 | * <return> Zero on success. | 92 | * <return> >= 0 on success. |
93 | * | 93 | * |
94 | * HISTORY | 94 | * HISTORY |
95 | * November 12, 1997 - Andrew E. Mileski | 95 | * November 12, 1997 - Andrew E. Mileski |
@@ -112,7 +112,7 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i) | |||
112 | memset(utf_o, 0, sizeof(struct ustr)); | 112 | memset(utf_o, 0, sizeof(struct ustr)); |
113 | pr_err("unknown compression code (%d) stri=%s\n", | 113 | pr_err("unknown compression code (%d) stri=%s\n", |
114 | cmp_id, ocu_i->u_name); | 114 | cmp_id, ocu_i->u_name); |
115 | return 0; | 115 | return -EINVAL; |
116 | } | 116 | } |
117 | 117 | ||
118 | ocu = ocu_i->u_name; | 118 | ocu = ocu_i->u_name; |
@@ -350,7 +350,8 @@ int udf_get_filename(struct super_block *sb, uint8_t *sname, int slen, | |||
350 | 350 | ||
351 | udf_build_ustr_exact(unifilename, sname, slen); | 351 | udf_build_ustr_exact(unifilename, sname, slen); |
352 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { | 352 | if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { |
353 | if (!udf_CS0toUTF8(filename, unifilename)) { | 353 | ret = udf_CS0toUTF8(filename, unifilename); |
354 | if (ret < 0) { | ||
354 | udf_debug("Failed in udf_get_filename: sname = %s\n", | 355 | udf_debug("Failed in udf_get_filename: sname = %s\n", |
355 | sname); | 356 | sname); |
356 | goto out2; | 357 | goto out2; |