Subject: bin/3352: In sh, sometimes ${#1} is not numeric
To: None <gnats-bugs@gnats.netbsd.org>
From: None <hiroy@netcom.com>
List: netbsd-bugs
Date: 03/18/1997 07:44:05
>Number: 3352
>Category: bin
>Synopsis: In sh, sometimes ${#1} is not numeric
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Mar 18 07:50:01 1997
>Last-Modified:
>Originator: Hiroyuki Ito
>Organization:
None
>Release: NetBSD-current 1997/03/15
>Environment:
System: NetBSD 1.2C i386
>Description:
(See fix.)
When stack grows, expdest and oexpdest may point different stack blocks.
>How-To-Repeat:
% sh
$ g () echo ${#1}
$ b=cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
$ g $b $b $b
66
$ g $b $b $b $b
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
$
>Fix:
*** expand.c.orig Tue Mar 4 15:36:59 1997
--- expand.c Tue Mar 18 10:53:46 1997
***************
*** 585,596 ****
if (set && subtype != VSPLUS) {
/* insert the value of the variable */
if (special) {
- char *exp, *oexpdest = expdest;
varvalue(var, varflags & VSQUOTE, flag & EXP_FULL);
if (subtype == VSLENGTH) {
! for (exp = oexpdest;exp != expdest; exp++)
! varlen++;
! expdest = oexpdest;
}
} else {
char const *syntax = (varflags & VSQUOTE) ? DQSYNTAX
--- 585,594 ----
if (set && subtype != VSPLUS) {
/* insert the value of the variable */
if (special) {
varvalue(var, varflags & VSQUOTE, flag & EXP_FULL);
if (subtype == VSLENGTH) {
! varlen = expdest - stackblock() - startloc;
! STADJUST(-varlen, expdest);
}
} else {
char const *syntax = (varflags & VSQUOTE) ? DQSYNTAX
>Audit-Trail:
>Unformatted: