LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Kyle Moffett <mrlinuxman@mac.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Ahmed S. Darwish" <darwish.07@gmail.com>,
	Adrian Bunk <bunk@kernel.org>,
	Casey Schaufler <casey@schaufler-ca.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-security-module@vger.kernel.org,
	LKML Kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] Fix isspace() and other ctype.h functions to ignore chars 128-255
Date: Wed, 7 Nov 2007 05:56:05 -0500
Message-ID: <DF41BB75-679F-4B6A-90F3-77DF228B6D3D@mac.com> (raw)
In-Reply-To: <alpine.LFD.0.999.0711060742100.15101@woody.linux-foundation.org>


[-- Attachment #1: Type: text/plain, Size: 1464 bytes --]

Originally isspace() and other similar functions in ctype.h ignored  
any character with the high bit set; however this was changed during  
the linux 2.1 days to map Latin-1.  As following Latin-1 will most  
likely break UTF-8 any any *other* encoding that is backwards- 
compatible with 7-bit-ASCII, change ctype.c to ignore such characters  
completely (the way they were before).  Linus seems to think this is  
a good thing, and he's the one that wrote the code in the first place.

Signed-off-by: Kyle Moffett <mrlinuxman@mac.com>

---

On Nov 06, 2007, at 10:53:08, Linus Torvalds wrote:
> On Tue, 6 Nov 2007, Kyle Moffett wrote:
>> Personally I think that isspace() accepting character 0xA0 is a bug
>
> I think I agree with you. As far as the kernel is concerned,  
> "isspace()" should just accept the obvious spaces (hardspace, tab,  
> newline), and *perhaps* the VT/FF kind of things.
>
> You should realize that the kernel <ctype.h> thing is *ancient*.  
> It's basically there from v0.01, and while the really original one  
> (I just checked) had all the non-ascii characters not trigger  
> anything, it was converted to be latin1 in the 2.1.x timeframe.
>
> That's a *loong* time ago. Way before UTF-8 and other things were  
> really common.
>
> So we should probably just make all the upper 128 bytes go back to  
> "don't trigger anything in ctype.h" - they'd not be spaces, but  
> they'd not be control characters or anything else either.


[-- Attachment #2: fix-isspace-patch.txt --]
[-- Type: text/plain, Size: 1362 bytes --]

 lib/ctype.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/lib/ctype.c b/lib/ctype.c
index d02ace1..ce2807a 100644
--- a/lib/ctype.c
+++ b/lib/ctype.c
@@ -24,13 +24,18 @@ _P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L,	/* 96-103 */
 _L,_L,_L,_L,_L,_L,_L,_L,			/* 104-111 */
 _L,_L,_L,_L,_L,_L,_L,_L,			/* 112-119 */
 _L,_L,_L,_P,_P,_P,_P,_C,			/* 120-127 */
+
+/*
+ * None of these match any type bits to avoid screwing up UTF-8 or any other
+ * 7-bit-ASCII-compatible encoding.
+ */
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 128-143 */
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 144-159 */
-_S|_SP,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,   /* 160-175 */
-_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,       /* 176-191 */
-_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,       /* 192-207 */
-_U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L,       /* 208-223 */
-_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,       /* 224-239 */
-_L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L};      /* 240-255 */
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 160-175 */
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 176-191 */
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 192-207 */
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 208-223 */
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 224-239 */
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};		/* 240-255 */
 
 EXPORT_SYMBOL(_ctype);

[-- Attachment #3: Type: text/plain, Size: 1 bytes --]



      reply index

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-02 20:50 [PATCH] Version 10 (2.6.24-rc1) Smack: Simplified Mandatory Access Control Kernel Casey Schaufler
2007-11-03 16:43 ` [PATCH] Smackv10: Smack rules grammar + their stateful parser Ahmed S. Darwish
2007-11-03 18:30   ` Kyle Moffett
2007-11-03 22:12     ` Ahmed S. Darwish
2007-11-04 12:28   ` Pavel Machek
2007-11-04 13:23     ` Ahmed S. Darwish
2007-11-04 16:37       ` Casey Schaufler
2007-11-05  9:41     ` Ahmed S. Darwish
2007-11-05 16:21       ` Linus Torvalds
2007-11-05 21:56         ` Tetsuo Handa
2007-11-06 10:00           ` Adrian Bunk
2007-11-06 12:27             ` Tetsuo Handa
2007-11-06 13:58               ` Adrian Bunk
2007-11-06 14:32                 ` Tetsuo Handa
2007-11-06 14:59                   ` Adrian Bunk
2007-11-06 15:27                     ` Tetsuo Handa
2007-11-06 22:42                       ` Adrian Bunk
2007-11-05 23:38         ` Ahmed S. Darwish
2007-11-06  8:06         ` Adrian Bunk
2007-11-06 15:39           ` Linus Torvalds
2007-11-06 23:00             ` Adrian Bunk
2007-11-06 23:08               ` Linus Torvalds
2007-11-07  0:07                 ` Adrian Bunk
2007-11-07  0:27                   ` Linus Torvalds
2007-11-07  0:43                     ` Adrian Bunk
2007-11-07  1:03                       ` Tetsuo Handa
2007-11-07  1:06                       ` Linus Torvalds
2007-11-07  1:59                         ` Adrian Bunk
2007-11-07  4:09                           ` Linus Torvalds
2007-11-07 15:08                           ` Alan Cox
2007-11-04 20:06   ` Ahmed S. Darwish
2007-11-05  0:56   ` [PATCH] Smackv10: Smack rules grammar + their stateful parser(2) Ahmed S. Darwish
2007-11-10 17:05     ` Jakob Oestergaard
2007-11-10 19:45       ` Ahmed S. Darwish
2007-11-11 12:44     ` Pavel Machek
2007-11-11 18:37       ` Ahmed S. Darwish
2007-11-06  6:33   ` [PATCH] Smackv10: Smack rules grammar + their stateful parser Adrian Bunk
2007-11-06  8:26     ` Kyle Moffett
2007-11-06  8:56       ` Adrian Bunk
2007-11-06 11:02         ` Alan Cox
2007-11-06 11:34         ` Ahmed S. Darwish
2007-11-06 11:47           ` Adrian Bunk
2007-11-06 12:23             ` Ahmed S. Darwish
2007-11-06 12:49               ` Kyle Moffett
2007-11-06 13:34                 ` Adrian Bunk
2007-11-06 14:05                   ` Ahmed S. Darwish
2007-11-06 14:10                     ` Adrian Bunk
2007-11-06 14:30                       ` Ahmed S. Darwish
2007-11-06 15:53                 ` Linus Torvalds
2007-11-07 10:56                   ` Kyle Moffett [this message]

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=DF41BB75-679F-4B6A-90F3-77DF228B6D3D@mac.com \
    --to=mrlinuxman@mac.com \
    --cc=akpm@linux-foundation.org \
    --cc=bunk@kernel.org \
    --cc=casey@schaufler-ca.com \
    --cc=darwish.07@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=torvalds@linux-foundation.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

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lkml.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lkml.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lkml.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lkml.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lkml.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lkml.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lkml.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lkml.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lkml.kernel.org/lkml/8 lkml/git/8.git
	git clone --mirror https://lkml.kernel.org/lkml/9 lkml/git/9.git
	git clone --mirror https://lkml.kernel.org/lkml/10 lkml/git/10.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lkml.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git