From: Andrew Gabbasov <andrew_gabbasov@mentor.com>
To: "'Jan Kara'" <jack@suse.cz>
Cc: Jan Kara <jack@suse.com>, <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v2 7/7] udf: Merge linux specific translation into CS0 conversion function
Date: Mon, 11 Jan 2016 16:31:47 +0300 [thread overview]
Message-ID: <000101d14c74$6c1a5f40$444f1dc0$@mentor.com> (raw)
In-Reply-To: <20160104132500.GC13014@quack.suse.cz>
Hi Jan,
> -----Original Message-----
> From: Jan Kara [mailto:jack@suse.cz]
> Sent: Monday, January 04, 2016 4:25 PM
> To: Gabbasov, Andrew
> Cc: Jan Kara; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH v2 7/7] udf: Merge linux specific translation into CS0
conversion function
[skipped]
> > + u_ch = cmp_id >> 3;
> > +
> > + ocu++;
> > + ocu_len--;
> > +
>
> Can we just check whether ocu_len is a multiple of u_ch here
> and bail out if not? That would save us some rounding below
> and also fix possible access beyond the end of the string
> in case fs is corrupted.
Yes, I think it can be done. I just wasn't sure if having
unaligned length is allowed or not, and tried to support
this case too. We can definitely return -EINVAL if ocu_len
is not a multiple of u_ch.
[skipped]
> > - for (i = 1; (i < ocu_len) && (str_o_len < str_max_len);) {
> > /* Expand OSTA compressed Unicode to Unicode */
> > - uint32_t c = ocu[i++];
> > - if (cmp_id == 16)
> > + c = ocu[i++];
> > + if (u_ch > 1)
> > c = (c << 8) | ocu[i++];
> >
> > + if (translate) {
> > + if ((c == '.') && (firstDots >= 0))
> > + firstDots++;
> > + else
> > + firstDots = -1;
> > +
> > + if (c == '/' || c == 0) {
> > + if (illChar)
> > + continue;
> > + illChar = 1;
> > + needsCRC = 1;
> > + c = ILLEGAL_CHAR_MARK;
> > + } else {
> > + illChar = 0;
> > + }
> > + }
> > +
> > len = conv_f(c, &str_o[str_o_len], str_max_len - str_o_len);
> > /* Valid character? */
> > - if (len >= 0)
> > + if (len >= 0) {
> > str_o_len += len;
> > - else
> > + } else {
> > str_o[str_o_len++] = '?';
> > + needsCRC = 1;
> > + }
>
> Umm, can you try factoring out body of this loop into a helper function
> and using it both during extension parsing and full name parsing?
I'll try to think about it. Although I'm not sure if it could become
a little overcomplicated since that helper could require too much internals
of this calling function.
> Also I think that checking whether the name is '.' or '..' could be moved
> just into the if (translate) below where you could just directly check it
like:
> if (str_o_len <= 2 && str_o[0] == '.' &&
> (str_o_len == 1 || str_o[1] == '.'))
Yes, you are right, it will be simpler.
I'll do it (and get rid of firstDots) in version 3 of the patch.
I'll also make all your suggested changes with empty lines and += u_ch.
Thanks.
Best regards,
Andrew
next prev parent reply other threads:[~2016-01-11 13:33 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-24 16:25 [PATCH v2 0/7] udf: rework name conversions to fix multi-bytes characters support Andrew Gabbasov
2015-12-24 16:25 ` [PATCH v2 1/7] udf: Prevent buffer overrun with multi-byte characters Andrew Gabbasov
2015-12-24 16:25 ` [PATCH v2 2/7] udf: Check output buffer length when converting name to CS0 Andrew Gabbasov
2016-01-04 17:19 ` Jan Kara
2015-12-24 16:25 ` [PATCH v2 3/7] udf: Parameterize output length in udf_put_filename Andrew Gabbasov
2015-12-24 16:25 ` [PATCH v2 4/7] udf: Join functions for UTF8 and NLS conversions Andrew Gabbasov
2015-12-24 16:25 ` [PATCH v2 5/7] udf: Adjust UDF_NAME_LEN to better reflect actual restrictions Andrew Gabbasov
2015-12-24 16:25 ` [PATCH v2 6/7] udf: Remove struct ustr as non-needed intermediate storage Andrew Gabbasov
2016-01-04 12:32 ` Jan Kara
2016-01-11 13:31 ` Andrew Gabbasov
2016-01-12 13:39 ` Jan Kara
2015-12-24 16:25 ` [PATCH v2 7/7] udf: Merge linux specific translation into CS0 conversion function Andrew Gabbasov
2016-01-04 13:25 ` Jan Kara
2016-01-11 13:31 ` Andrew Gabbasov [this message]
2016-01-04 13:30 ` [PATCH v2 0/7] udf: rework name conversions to fix multi-bytes characters support 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='000101d14c74$6c1a5f40$444f1dc0$@mentor.com' \
--to=andrew_gabbasov@mentor.com \
--cc=jack@suse.com \
--cc=jack@suse.cz \
--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