- fix crash when bad substitution is used

This commit is contained in:
Michal Hlavinka 2011-01-05 08:42:27 +01:00
parent eaeaf0e7f4
commit a3f709ba70
2 changed files with 55 additions and 1 deletions

47
mksh-39c-fixsusbst.patch Normal file
View File

@ -0,0 +1,47 @@
diff -up mksh-39c/check.t.fixsubst mksh-39c/check.t
--- mksh-39c/check.t.fixsubst 2011-01-04 15:55:30.493395051 +0100
+++ mksh-39c/check.t 2011-01-04 15:57:48.681133798 +0100
@@ -4452,6 +4452,22 @@ expected-stderr-pattern:
/bad substitution/
expected-exit: 1
---
+name: xxx-variable-syntax-2
+stdin:
+ set 0
+ echo ${*:0}
+expected-stderr-pattern:
+ /bad substitution/
+expected-exit: 1
+---
+name: xxx-variable-syntax-3
+stdin:
+ set -A foo 0
+ echo ${foo[*]:0}
+expected-stderr-pattern:
+ /bad substitution/
+expected-exit: 1
+---
name: xxx-substitution-eval-order
description:
Check order of evaluation of expressions
diff -up mksh-39c/eval.c.fixsubst mksh-39c/eval.c
--- mksh-39c/eval.c.fixsubst 2010-02-25 21:18:39.000000000 +0100
+++ mksh-39c/eval.c 2011-01-04 15:55:30.500394934 +0100
@@ -1016,6 +1016,8 @@ varsub(Expand *xp, const char *sp, const
case '=': /* can't assign to a vector */
case '%': /* can't trim a vector (yet) */
case '#':
+ case '0':
+ case '/':
return (-1);
}
if (e->loc->argc == 0) {
@@ -1039,6 +1041,8 @@ varsub(Expand *xp, const char *sp, const
case '%': /* can't trim a vector (yet) */
case '#':
case '?':
+ case '0':
+ case '/':
return (-1);
}
XPinit(wv, 32);

View File

@ -3,7 +3,7 @@
Summary: MirBSD enhanced version of the Korn Shell
Name: mksh
Version: 39c
Release: 3%{?dist}
Release: 4%{?dist}
# BSD (setmode.c), ISC (strlcpy.c), MirOS (the rest)
License: MirOS and ISC and BSD
Group: System Environment/Shells
@ -12,6 +12,7 @@ Source0: http://www.mirbsd.org/MirOS/dist/mir/%{name}/%{name}-R%{versio
Source1: dot-mkshrc
Patch1: mksh-39c-fixsetx.patch
Patch2: mksh-39c-dblalias.patch
Patch3: mksh-39c-fixsusbst.patch
Requires(post): grep
Requires(postun): sed
BuildRequires: util-linux, ed
@ -37,6 +38,9 @@ mv %{name}/* . && rm -rf %{name}
# from upstream cvs, for mksh < "R39 2010/07/21", rhbz#616777
%patch2 -p1 -b .dblalias
# from upstream cvs, for mksh < "R39 2010/05/17", rhbz#618274
%patch3 -p1 -b .fixsubst
%build
CFLAGS="$RPM_OPT_FLAGS" sh Build.sh -r -combine
@ -78,6 +82,9 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man1/%{name}.1*
%changelog
* Tue Jan 04 2011 Michal Hlavinka <mhlavink@redhat.com> 39c-4
- fix crash when bad substitution is used
* Wed Jul 21 2010 Michal Hlavinka <mhlavink@redhat.com> 39c-3
- fix crash when alias contains alias
- fix crash when xtrace is enabled