experimental diff:
From: Todd C. Miller <Todd.Miller@courtesan.com> The following ksh diff needs wide testing. It does the following: 1) proper error message for bad substitution. Before: $ echo ${a[@]:foo} ksh: : bad substitution After: $ echo ${a[@]:foo} ksh: ${a[@]:foo}: bad substitution 2) fix a core dump for "echo ${a[@]:?foo}". 3) fix a use-after-free bug (from otto@)
This commit is contained in:
9
eval.c
9
eval.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: eval.c,v 1.10 2004/12/10 16:01:34 tg Exp $ */
|
||||
/** $MirBSD: eval.c,v 1.11 2004/12/10 22:21:25 tg Exp $ */
|
||||
/* $OpenBSD: eval.c,v 1.16 2004/12/08 21:23:18 millert Exp $ */
|
||||
|
||||
/*
|
||||
@ -10,7 +10,7 @@
|
||||
#include "ksh_dir.h"
|
||||
#include "ksh_stat.h"
|
||||
|
||||
__RCSID("$MirBSD: eval.c,v 1.10 2004/12/10 16:01:34 tg Exp $");
|
||||
__RCSID("$MirBSD: eval.c,v 1.11 2004/12/10 22:21:25 tg Exp $");
|
||||
|
||||
/*
|
||||
* string expansion
|
||||
@ -287,12 +287,12 @@ expand(char *cp, XPtrV *wp, int f)
|
||||
char endc;
|
||||
char *str, *end;
|
||||
|
||||
sp = varname - 2; /* restore sp */
|
||||
end = (char *) wdscan(sp, CSUBST);
|
||||
/* ({) the } or x is already skipped */
|
||||
endc = *end;
|
||||
*end = EOS;
|
||||
str = snptreef((char *) 0, 64, "%S",
|
||||
varname - 1);
|
||||
str = snptreef(NULL, 64, "%S", sp);
|
||||
*end = endc;
|
||||
errorf("%s: bad substitution", str);
|
||||
}
|
||||
@ -801,6 +801,7 @@ varsub(Expand *xp, char *sp, char *word, int *stypep, int *slenp)
|
||||
case '=': /* can't assign to a vector */
|
||||
case '%': /* can't trim a vector (yet) */
|
||||
case '#':
|
||||
case '?':
|
||||
return -1;
|
||||
}
|
||||
XPinit(wv, 32);
|
||||
|
Reference in New Issue
Block a user