Subject: bin/1190: "tr" is not 8-bit clean
To: None <gnats-admin@sun-lamp.pc.cs.cmu.edu>
From: None <gson@araneus.pp.fi>
List: netbsd-bugs
Date: 07/03/1995 12:20:05
>Number: 1190
>Category: bin
>Synopsis: "tr" is not 8-bit clean
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Jul 3 12:20:02 1995
>Originator: Andreas Gustafsson
>Organization:
Araneus Information Systems Oy
>Release: NetBSD-current i386 binary snapshot of May 15, 1995
>Environment:
System: NetBSD araneus.pp.fi 1.0A NetBSD 1.0A (GUANO) #4: Mon Jul 3 17:08:45 EET DST 1995 gson@araneus.pp.fi:/usr/src/sys/arch/i386/compile/GUANO i386
>Description:
When /usr/bin/tr is given arguments containing characters
with the eighth bit set, it behaves erratically. This is due
to sign extending such characters into negative numbers and
then using those negative numbers as array indices.
>How-To-Repeat:
Uudecode the following shell script and then run it with itself
as standard input like this: "sh trbug <trbug". The output should
not be identical to the input, but it is.
begin 644 trbug
7(R$O8FEN+W-H"G1R("?D]B<@)V%O)PKW
`
end
>Fix:
Apply this patch to /usr/src/usr.bin/tr/extern.h.
*** extern.h.orig Mon Jul 3 17:52:33 1995
--- extern.h Mon Jul 3 17:38:21 1995
***************
*** 43,47 ****
int equiv[2]; /* equivalence set */
int *set; /* set of characters */
! char *str; /* user's string */
} STR;
--- 43,47 ----
int equiv[2]; /* equivalence set */
int *set; /* set of characters */
! unsigned char *str; /* user's string */
} STR;
>Audit-Trail:
>Unformatted: