summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2010-10-13 23:29:09 +0000
committerobrien <obrien@FreeBSD.org>2010-10-13 23:29:09 +0000
commit04029327665ca3c97ae07cae698d5df760f2b68e (patch)
tree21a2e1390b3cbd0e8029830cf4195a75dba0d1e7 /tools
parent256615c9b37c8059eef0e130fbf813607a5396a8 (diff)
downloadFreeBSD-src-04029327665ca3c97ae07cae698d5df760f2b68e.zip
FreeBSD-src-04029327665ca3c97ae07cae698d5df760f2b68e.tar.gz
Do not assume in growstackstr() that a "precious" character will be
immediately written into the stack after the call. Instead let the caller manage the "space left". Previously, growstackstr()'s assumption causes problems with STACKSTRNUL() where we want to be able to turn a stack into a C string, and later pretend the NUL is not there. This fixes a bug in STACKSTRNUL() (that grew the stack) where: 1. STADJUST() called after a STACKSTRNUL() results in an improper adjust. This can be seen in ${var%pattern} and ${var%%pattern} evaluation. 2. Memory leak in STPUTC() called after a STACKSTRNUL(). Reviewed by: jilles
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/bin/sh/expansion/trim4.015
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/expansion/trim4.0 b/tools/regression/bin/sh/expansion/trim4.0
new file mode 100644
index 0000000..1000bd3
--- /dev/null
+++ b/tools/regression/bin/sh/expansion/trim4.0
@@ -0,0 +1,15 @@
+# $FreeBSD$
+
+v1=/homes/SOME_USER
+v2=
+v3=C123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
+
+# Trigger bug in VSTRIMRIGHT processing STADJUST() call in expand.c:subevalvar()
+while [ ${#v2} -lt 2000 ]; do
+ v4="${v2} ${v1%/*} $v3"
+ if [ ${#v4} -ne $((${#v2} + ${#v3} + 8)) ]; then
+ echo bad: ${#v4} -ne $((${#v2} + ${#v3} + 8))
+ fi
+ v2=x$v2
+ v3=y$v3
+done
OpenPOWER on IntegriCloud