NetBSD Problem Report #35423

From www@NetBSD.org  Mon Jan 15 04:20:22 2007
Return-Path: <www@NetBSD.org>
Received: by narn.NetBSD.org (Postfix, from userid 31301)
	id DAEED63B84E; Mon, 15 Jan 2007 04:20:22 +0000 (UTC)
Message-Id: <20070115042022.DAEED63B84E@narn.NetBSD.org>
Date: Mon, 15 Jan 2007 04:20:22 +0000 (UTC)
From: rillig@NetBSD.org
Reply-To: rillig@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: /bin/sh cannot open files whose name contains the characters 0x81 or 0x88
X-Send-Pr-Version: www-1.0

>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:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 15 04:25:00 +0000 2007
>Closed-Date:    Sat Apr 09 11:07:39 +0000 2016
>Last-Modified:  Sat Apr 09 11:07:39 +0000 2016
>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,

>Release-Note:

>Audit-Trail:
From: Christian Biere <christianbiere@gmx.de>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: Re: bin/35423: /bin/sh: Character 0x88 is illegal in redirects,
	0x81 too
Date: Tue, 29 Apr 2008 04:35:18 +0200

 David Holland wrote:
 > On Sun, Apr 27, 2008 at 03:10:01PM +0000, Christian Biere wrote:
 >  > /bin/sh cannot handle filenames that contain characters \x81 or
 >  > \x88 in redirects because it strips these characters before
 >  > processing the string.
 > 
 > This duplicates part of bin/19832.

 bin/35423 is another duplicate.

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/35423 CVS commit: src/bin/sh
Date: Wed, 16 Mar 2016 11:44:35 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Wed Mar 16 15:44:35 UTC 2016

 Modified Files:
 	src/bin/sh: expand.c

 Log Message:
 PR/19832, PR/35423: Fix handling 0x81 and 0x82 characters in expansions
 ($VAR etc) that are used to generate filenames for redirections. (from kre)


 To generate a diff of this commit:
 cvs rdiff -u -r1.96 -r1.97 src/bin/sh/expand.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Mon, 04 Apr 2016 12:36:58 +0000
State-Changed-Why:
This is probably fixed, please confirm!


State-Changed-From-To: feedback->closed
State-Changed-By: rillig@NetBSD.org
State-Changed-When: Sat, 09 Apr 2016 11:07:39 +0000
State-Changed-Why:
As of expand.c, 1.101, this is fixed.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.