summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortegge <tegge@FreeBSD.org>2001-09-19 20:16:38 +0000
committertegge <tegge@FreeBSD.org>2001-09-19 20:16:38 +0000
commitb0e7279ba20f9919fc823af5abb36352b0220380 (patch)
tree25186f8d9f0d146ebf6f626162b85d15ec544c62
parent0c39138a0b8e8641570b8e60e24b63c5226b67dd (diff)
downloadFreeBSD-src-b0e7279ba20f9919fc823af5abb36352b0220380.zip
FreeBSD-src-b0e7279ba20f9919fc823af5abb36352b0220380.tar.gz
Don't check uninitialized memory for having the shell control character
value CTLARI since this might break expansion of arithmetic expressions. Don't access memory below start of stackblock. Problem analyzed by hunt@iprg.nokia.com, slightly different patch applied. PR: 24443 Submitted by: hunt@iprg.nokia.com
-rw-r--r--bin/sh/expand.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/bin/sh/expand.c b/bin/sh/expand.c
index f1d0d69..8d62830 100644
--- a/bin/sh/expand.c
+++ b/bin/sh/expand.c
@@ -397,12 +397,12 @@ expari(flag)
CHECKSTRSPACE(12 - 2, expdest);
USTPUTC('\0', expdest);
start = stackblock();
- p = expdest;
- while (*p != CTLARI && p >= start)
+ p = expdest - 2;
+ while (p >= start && *p != CTLARI)
--p;
- if (*p != CTLARI)
+ if (p < start || *p != CTLARI)
error("missing CTLARI (shouldn't happen)");
- if (p > start && *(p-1) == CTLESC)
+ if (p > start && *(p - 1) == CTLESC)
for (p = start; *p != CTLARI; p++)
if (*p == CTLESC)
p++;
OpenPOWER on IntegriCloud