mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Liyang Hu <liyang@nerv.cx>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] Bug in NLS UTF-8 code
Date: Mon, 1 Apr 2002 01:00:56 +0100	[thread overview]
Message-ID: <20020401000056.GA5896@cam.ac.uk> (raw)

Hi,

I've recently (actually, last month, but I had been a bit too busy
since then) come across a wee problem, in what I originally thought
was the VFAT code -- having `utf8' as one of the options, creating
UTF-8 file names on a VFAT partition mysteriously gains a couple of
(random) characters just after the UTF-8 escaped character: eg.
touch "fooCbar" where C is an UTF-8 escape sequence ends up creating
a file named "fooCRbar". (R being some random character.)

I eventually tracked it down to one line in fs/nls/nls_base.c -- the
UCS-2 (wchar_t) string pointer was being incremented too fast. After
consulting Ogawa Hirofumi-san on the subject, he mentioned that
include/linux/nls.h also needs to be changed for proper UTF-8
support in the NLS code.

Patch enclosed below.

/Liyang

----8<----snip----8<----

--- kernel-source-2.4.18/fs/nls/nls_base.c.orig	Mon Apr  1 00:26:37 2002
+++ kernel-source-2.4.18-nls/fs/nls/nls_base.c	Mon Apr  1 00:26:57 2002
@@ -1,5 +1,5 @@
 /*
- * linux/fs/nls.c
+ * linux/fs/nls_base.c
  *
  * Native language support--charsets and unicode translations.
  * By Gordon Chaffee 1996, 1997
@@ -93,7 +93,7 @@
 				ip++;
 				n--;
 			} else {
-				op += size;
+				op++;
 				ip += size;
 				n -= size;
 			}
--- kernel-source-2.4.18/include/linux/nls.h.orig	Fri Jul 20 20:53:03 2001
+++ kernel-source-2.4.18-nls/include/linux/nls.h	Mon Apr  1 00:28:16 2002
@@ -18,7 +18,7 @@
 };
 
 /* this value hold the maximum octet of charset */
-#define NLS_MAX_CHARSET_SIZE 3
+#define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
 
 /* nls.c */
 extern int register_nls(struct nls_table *);

----8<----snip----8<----

-- 
.--{ Liyang HU }--{ http://nerv.cx/ }--{ Caius@Cam }--{ ICQ: 39391385 }--.
| :: Well, we just happen to *have* an infinite number of monkeys! ::::: |
| ::::::: http://stats.distributed.net/rc5-64/psummary.php3?id=284324 :: |

                 reply	other threads:[~2002-04-01  0:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20020401000056.GA5896@cam.ac.uk \
    --to=liyang@nerv.cx \
    --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

all inboxes | Powered by JetHome®