Subject: bin/35423: /bin/sh cannot open files whose name contains the characters 0x81 or 0x88
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <rillig@NetBSD.org>
List: netbsd-bugs
Date: 01/15/2007 04:25:00
>Number:         35423
>Category:       bin
>Synopsis:       /bin/sh cannot open files whose name contains the characters 0x81 or 0x88
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 15 04:25:00 +0000 2007
>Originator:     Roland Illig
>Release:        3.0
>Organization:
>Environment:
NetBSD bacc.roland-illig.de 4.99.4 NetBSD 4.99.4 (GENERIC) #1: Sat Dec  9 17:31:12 CET 2006  build@bacc.roland-illig.de:/home/scratch/build/NetBSD/2006-12/work/sys/arch/i386/compile/GENERIC i386

>Description:

>How-To-Repeat:
mkdir tmp
cd tmp
perl -e 'map { open(F, ">", chr($_)) } (0..255)'
rm \'
for i in *; do echo "$i" | hexdump -C; sh -c "read line < '$i'"; done 2>&1 | less

...
00000000  80 0a                                             |..|
00000002
00000000  81 0a                                             |..|
00000002
cannot open : no such file
00000000  82 0a                                             |..|
00000002
00000000  83 0a                                             |..|
00000002
00000000  84 0a                                             |..|
00000002
00000000  85 0a                                             |..|
00000002
00000000  86 0a                                             |..|
00000002
00000000  87 0a                                             |..|
00000002
00000000  88 0a                                             |..|
00000002
cannot open : no such file
00000000  89 0a                                             |..|
00000002
...

>Fix:
Maybe somewhere in syntax.c. When I compile it with -funsigned-char, it gives me this error:

syntax.c:17: error: array index in initializer exceeds array bounds

The preprocessed source code is:
16: const char basesyntax[257] = { 10,
17:    [('\201' + 1 - (-0x7f-1)) ... ('\211' + 1 - (-0x7f-1))] = 11,
18:    [('\n' + 1 - (-0x7f-1))] = 1,