From b0e7279ba20f9919fc823af5abb36352b0220380 Mon Sep 17 00:00:00 2001 From: tegge Date: Wed, 19 Sep 2001 20:16:38 +0000 Subject: 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 --- bin/sh/expand.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bin/sh/expand.c') 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++; -- cgit v1.1