From: Jan Kara <jack@suse.cz>
To: Fabian Frederick <fabf@skynet.be>
Cc: linux-kernel@vger.kernel.org, Jan Kara <jack@suse.cz>
Subject: Re: [PATCH V2 4/9 linux-next] udf: improve error management in udf_CS0toUTF8()
Date: Thu, 9 Apr 2015 13:53:47 +0200 [thread overview]
Message-ID: <20150409115347.GJ18044@quack.suse.cz> (raw)
In-Reply-To: <20150409083607.GD18044@quack.suse.cz>
[-- Attachment #1: Type: text/plain, Size: 3737 bytes --]
On Thu 09-04-15 10:36:07, Jan Kara wrote:
> On Wed 08-04-15 21:23:54, Fabian Frederick wrote:
> > 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>
> After some thought it's probably better API that udf_CS0toUTF8() simply
> returns 0 when 0-lenght string is provided as an input (there's nothing
> invalid in that from the point of view of that conversion functions). We
> cannot actually ever call udf_CS0toUTF8() with such string currently but I
> think it's better for future. So I've changed this and merged the patch.
Just for reference, attached is the resulting patch.
Honza
> > ---
> > fs/udf/super.c | 23 ++++++++++++++---------
> > fs/udf/unicode.c | 9 +++++----
> > 2 files changed, 19 insertions(+), 13 deletions(-)
> >
> > diff --git a/fs/udf/super.c b/fs/udf/super.c
> > index 6299f34..c6a8f5f 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:
> > diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
> > index 41c3bef..9008a36 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)
> > * both of type "struct ustr *"
> > *
> > * POST-CONDITIONS
> > - * <return> Zero on success.
> > + * <return> >= 0 on success.
> > *
> > * HISTORY
> > * November 12, 1997 - Andrew E. Mileski
> > @@ -104,7 +104,7 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i)
> > ocu_len = ocu_i->u_len;
> > if (ocu_len == 0) {
> > memset(utf_o, 0, sizeof(struct ustr));
> > - return 0;
> > + return -EINVAL;
> > }
> >
> > cmp_id = ocu_i->u_cmpID;
> > @@ -112,7 +112,7 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i)
> > memset(utf_o, 0, sizeof(struct ustr));
> > pr_err("unknown compression code (%d) stri=%s\n",
> > cmp_id, ocu_i->u_name);
> > - return 0;
> > + return -EINVAL;
> > }
> >
> > ocu = ocu_i->u_name;
> > @@ -350,7 +350,8 @@ int udf_get_filename(struct super_block *sb, uint8_t *sname, int slen,
> >
> > udf_build_ustr_exact(unifilename, sname, slen);
> > if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
> > - if (!udf_CS0toUTF8(filename, unifilename)) {
> > + ret = udf_CS0toUTF8(filename, unifilename);
> > + if (ret < 0) {
> > udf_debug("Failed in udf_get_filename: sname = %s\n",
> > sname);
> > goto out2;
> > --
> > 1.9.1
> >
> --
> Jan Kara <jack@suse.cz>
> SUSE Labs, CR
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
[-- Attachment #2: 0004-udf-improve-error-management-in-udf_CS0toUTF8.patch --]
[-- Type: text/x-patch, Size: 2783 bytes --]
>From 2fd89b7d8600488b00eb2d826750f3800fd5fd9b Mon Sep 17 00:00:00 2001
From: Fabian Frederick <fabf@skynet.be>
Date: Wed, 8 Apr 2015 21:23:54 +0200
Subject: [PATCH 4/8] 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>
---
fs/udf/super.c | 23 ++++++++++++++---------
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)
#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:
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)
* both of type "struct ustr *"
*
* POST-CONDITIONS
- * <return> Zero on success.
+ * <return> >= 0 on success.
*
* HISTORY
* November 12, 1997 - Andrew E. Mileski
@@ -112,7 +112,7 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i)
memset(utf_o, 0, sizeof(struct ustr));
pr_err("unknown compression code (%d) stri=%s\n",
cmp_id, ocu_i->u_name);
- return 0;
+ return -EINVAL;
}
ocu = ocu_i->u_name;
@@ -350,7 +350,8 @@ int udf_get_filename(struct super_block *sb, uint8_t *sname, int slen,
udf_build_ustr_exact(unifilename, sname, slen);
if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
- if (!udf_CS0toUTF8(filename, unifilename)) {
+ ret = udf_CS0toUTF8(filename, unifilename);
+ if (ret < 0) {
udf_debug("Failed in udf_get_filename: sname = %s\n",
sname);
goto out2;
--
2.1.4
next prev parent reply other threads:[~2015-04-09 11:53 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-08 19:23 [PATCH V2 0/9 linux-next] udf: improve error management Fabian Frederick
2015-04-08 19:23 ` [PATCH V2 1/9 linux-next] udf: udf_get_filename(): return -ENOMEM when allocation fails Fabian Frederick
2015-04-09 8:21 ` Jan Kara
2015-04-08 19:23 ` [PATCH V2 2/9 linux-next] udf: remove unnecessary test in udf_build_ustr_exact() Fabian Frederick
2015-04-09 8:25 ` Jan Kara
2015-04-08 19:23 ` [PATCH V2 3/9 linux-next] udf: unicode: update function name in comments Fabian Frederick
2015-04-09 8:26 ` Jan Kara
2015-04-08 19:23 ` [PATCH V2 4/9 linux-next] udf: improve error management in udf_CS0toUTF8() Fabian Frederick
2015-04-09 8:36 ` Jan Kara
2015-04-09 11:53 ` Jan Kara [this message]
2015-04-08 19:23 ` [PATCH V2 5/9 linux-next] udf: improve error management in udf_CS0toNLS() Fabian Frederick
2015-04-09 8:37 ` Jan Kara
2015-04-09 11:54 ` Jan Kara
2015-04-08 19:23 ` [PATCH V2 6/9 linux-next] udf: bug on exotic flag in udf_get_filename() Fabian Frederick
2015-04-09 8:39 ` Jan Kara
2015-04-08 19:23 ` [PATCH V2 7/9 linux-next] udf: return error when newIndex is 0 in udf_translate_to_linux() Fabian Frederick
2015-04-09 8:51 ` Jan Kara
2015-04-09 11:55 ` Jan Kara
2015-04-08 19:23 ` [PATCH V2 8/9 linux-next] udf: propagate udf_get_filename() errors Fabian Frederick
2015-04-09 9:27 ` Jan Kara
2015-04-08 19:23 ` [PATCH V2 9/9 linux-next] udf: add function definition for udf_find_entry() Fabian Frederick
2015-04-09 9:26 ` Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150409115347.GJ18044@quack.suse.cz \
--to=jack@suse.cz \
--cc=fabf@skynet.be \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome