Signed-off-by: Vladimir Serbinenko <phcoder@xxxxxxxxx> --- fs/isofs/joliet.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/fs/isofs/joliet.c b/fs/isofs/joliet.c index a048de8..d85e842 100644 --- a/fs/isofs/joliet.c +++ b/fs/isofs/joliet.c @@ -16,22 +16,35 @@ static int uni16_to_x8(unsigned char *ascii, __be16 *uni, int len, struct nls_table *nls) { - __be16 *ip, ch; + __be16 *ip, ch[2]; unsigned char *op; ip = uni; op = ascii; - while ((ch = get_unaligned(ip)) && len) { + ch[1] = get_unaligned(ip); + + while (len) { int llen; - llen = nls->uni2char(be16_to_cpu(ch), op, NLS_MAX_CHARSET_SIZE); + int s; + unicode_t uni; + ch[0] = ch[1]; + if (len > 1) + ch[1] = get_unaligned(ip + 1); + s = utf16s_to_unicode(ch, len > 1 ? 2 : 1, UTF16_BIG_ENDIAN, + &uni); + if (s <= 0) { + llen = -1; + s = 1; + } else + llen = nls->uni2char(uni, op, NLS_MAX_CHARSET_SIZE); if (llen > 0) op += llen; else *op++ = '?'; - ip++; + ip += s; - len--; + len -= s; } *op = 0; return (op - ascii); -- 1.7.10 -- Regards Vladimir 'φ-coder/phcoder' Serbinenko
Attachment:
signature.asc
Description: OpenPGP digital signature