Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/sh PR/50179: Timo Buhrmester: sh(1) variable expansion bug
details: https://anonhg.NetBSD.org/src/rev/a20e02a009ab
branches: trunk
changeset: 340203:a20e02a009ab
user: christos <christos%NetBSD.org@localhost>
date: Thu Aug 27 07:46:47 2015 +0000
description:
PR/50179: Timo Buhrmester: sh(1) variable expansion bug
diffstat:
bin/sh/expand.c | 28 ++++++++++++++--------------
1 files changed, 14 insertions(+), 14 deletions(-)
diffs (106 lines):
diff -r d41620496ac5 -r a20e02a009ab bin/sh/expand.c
--- a/bin/sh/expand.c Thu Aug 27 06:28:09 2015 +0000
+++ b/bin/sh/expand.c Thu Aug 27 07:46:47 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: expand.c,v 1.92 2015/06/06 15:22:58 joerg Exp $ */
+/* $NetBSD: expand.c,v 1.93 2015/08/27 07:46:47 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)expand.c 8.5 (Berkeley) 5/15/95";
#else
-__RCSID("$NetBSD: expand.c,v 1.92 2015/06/06 15:22:58 joerg Exp $");
+__RCSID("$NetBSD: expand.c,v 1.93 2015/08/27 07:46:47 christos Exp $");
#endif
#endif /* not lint */
@@ -98,7 +98,7 @@
STATIC void argstr(char *, int);
STATIC char *exptilde(char *, int);
STATIC void expbackq(union node *, int, int);
-STATIC int subevalvar(char *, char *, int, int, int, int);
+STATIC int subevalvar(char *, char *, int, int, int, int, int);
STATIC char *evalvar(char *, int);
STATIC int varisset(char *, int);
STATIC void varvalue(char *, int, int, int);
@@ -495,7 +495,7 @@
STATIC int
-subevalvar(char *p, char *str, int strloc, int subtype, int startloc, int varflags)
+subevalvar(char *p, char *str, int strloc, int subtype, int startloc, int varflags, int quotes)
{
char *startp;
char *loc = NULL;
@@ -548,10 +548,10 @@
for (loc = startp; loc < str; loc++) {
c = *loc;
*loc = '\0';
- if (patmatch(str, startp, varflags & VSQUOTE))
+ if (patmatch(str, startp, quotes))
goto recordleft;
*loc = c;
- if ((varflags & VSQUOTE) && *loc == CTLESC)
+ if (quotes && *loc == CTLESC)
loc++;
}
return 0;
@@ -560,11 +560,11 @@
for (loc = str - 1; loc >= startp;) {
c = *loc;
*loc = '\0';
- if (patmatch(str, startp, varflags & VSQUOTE))
+ if (patmatch(str, startp, quotes))
goto recordleft;
*loc = c;
loc--;
- if ((varflags & VSQUOTE) && loc > startp &&
+ if (quotes && loc > startp &&
*(loc - 1) == CTLESC) {
for (q = startp; q < loc; q++)
if (*q == CTLESC)
@@ -577,10 +577,10 @@
case VSTRIMRIGHT:
for (loc = str - 1; loc >= startp;) {
- if (patmatch(str, loc, varflags & VSQUOTE))
+ if (patmatch(str, loc, quotes))
goto recordright;
loc--;
- if ((varflags & VSQUOTE) && loc > startp &&
+ if (quotes && loc > startp &&
*(loc - 1) == CTLESC) {
for (q = startp; q < loc; q++)
if (*q == CTLESC)
@@ -593,9 +593,9 @@
case VSTRIMRIGHTMAX:
for (loc = startp; loc < str - 1; loc++) {
- if (patmatch(str, loc, varflags & VSQUOTE))
+ if (patmatch(str, loc, quotes))
goto recordright;
- if ((varflags & VSQUOTE) && *loc == CTLESC)
+ if (quotes && *loc == CTLESC)
loc++;
}
return 0;
@@ -763,7 +763,7 @@
STPUTC('\0', expdest);
patloc = expdest - stackblock();
if (subevalvar(p, NULL, patloc, subtype,
- startloc, varflags) == 0) {
+ startloc, varflags, quotes) == 0) {
int amount = (expdest - stackblock() - patloc) + 1;
STADJUST(-amount, expdest);
}
@@ -776,7 +776,7 @@
case VSQUESTION:
if (set)
break;
- if (subevalvar(p, var, 0, subtype, startloc, varflags)) {
+ if (subevalvar(p, var, 0, subtype, startloc, varflags, quotes)) {
varflags &= ~VSNUL;
/*
* Remove any recorded regions beyond
Home |
Main Index |
Thread Index |
Old Index