rpms/mksh/EL-4 mksh-36-alias.patch,NONE,1.1 mksh.spec,1.16,1.17

Robert Scheck robert at fedoraproject.org
Tue Dec 2 21:51:29 UTC 2008


Author: robert

Update of /cvs/pkgs/rpms/mksh/EL-4
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv15344/EL-4

Modified Files:
	mksh.spec 
Added Files:
	mksh-36-alias.patch 
Log Message:
Upstream patch for command hang/high cpu workload (#474115)


mksh-36-alias.patch:

--- NEW FILE mksh-36-alias.patch ---
Patch by Thorsten Glaser <tg at mirbsd.org> for mksh <= 36, to solve
some kind of "bug" resulting in command hang in mksh and also high
cpu workload. For more information, please have a look to Red Hat
Bugzilla ID #474115. And this patch is already in upstream version
control system and will be included in upstream's next release.

--- mksh-36/check.t		2008-10-24 23:36:05.000000000 +0200
+++ mksh-36/check.t.alias	2008-12-02 22:36:13.000000000 +0100
@@ -7,7 +7,7 @@
 # http://www.research.att.com/~gsf/public/ifs.sh
 
 expected-stdout:
-	@(#)MIRBSD KSH R36 2008/10/24
+	@(#)MIRBSD KSH R36 2008/10/24 RedHat-1
 description:
 	Check version of shell.
 stdin:
@@ -151,6 +151,20 @@
 	hi
 	there
 ---
+name: alias-9
+description:
+	Check that recursion is detected/avoided in aliases.
+time-limit: 3
+stdin:
+	echo -n >tf
+	alias ls=ls
+	ls
+	echo $(ls)
+	exit 0
+expected-stdout:
+	tf
+	tf
+---
 name: arith-lazy-1
 description:
 	Check that only one side of ternary operator is evaluated
--- mksh-36/lex.c		2008-10-10 23:31:05.000000000 +0200
+++ mksh-36/lex.c.alias		2008-12-02 22:33:53.000000000 +0100
@@ -904,16 +904,24 @@
 				/* prefer functions over aliases */
 				ktdelete(p);
 			else {
-				Source *s;
+				Source *s = source;
 
-				for (s = source; s->type == SALIAS; s = s->next)
+				while (s->flags & SF_HASALIAS)
 					if (s->u.tblp == p)
 						return LWORD;
+					else
+						s = s->next;
 				/* push alias expansion */
 				s = pushs(SALIAS, source->areap);
 				s->start = s->str = p->val.s;
 				s->u.tblp = p;
+				s->flags |= SF_HASALIAS;
 				s->next = source;
+				if (source->type == SEOF) {
+					/* prevent infinite recursion at EOS */
+					source->u.tblp = p;
+					source->flags |= SF_HASALIAS;
+				}
 				source = s;
 				afree(yylval.cp, ATEMP);
 				goto Again;
--- mksh-36/sh.h		2008-10-24 23:36:06.000000000 +0200
+++ mksh-36/sh.h.alias		2008-12-02 22:35:27.000000000 +0100
@@ -102,7 +102,7 @@
 #ifdef EXTERN
 __RCSID("$MirOS: src/bin/mksh/sh.h,v 1.245 2008/10/24 21:35:43 tg Exp $");
 #endif
-#define MKSH_VERSION "R36 2008/10/24"
+#define MKSH_VERSION "R36 2008/10/24 RedHat-1"
 
 #ifndef MKSH_INCLUDES_ONLY
 
@@ -1117,7 +1117,7 @@
 	union {
 		const char **strv; /* string [] */
 		struct shf *shf;   /* shell file */
-		struct tbl *tblp;  /* alias (SALIAS) */
+		struct tbl *tblp;  /* alias (SF_HASALIAS) */
 		char *freeme;	   /* also for SREREAD */
 	} u;
 	int	line;		/* line number */
@@ -1148,6 +1148,7 @@
 #define SF_ALIASEND	BIT(2)	/* faking space at end of alias */
 #define SF_TTY		BIT(3)	/* type == SSTDIN & it is a tty */
 #define SF_FIRST	BIT(4)	/* initial state (to ignore UTF-8 BOM) */
+#define SF_HASALIAS	BIT(5)	/* u.tblp valid (SALIAS, SEOF) */
 
 typedef union {
 	int i;


Index: mksh.spec
===================================================================
RCS file: /cvs/pkgs/rpms/mksh/EL-4/mksh.spec,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- mksh.spec	25 Oct 2008 15:02:57 -0000	1.16
+++ mksh.spec	2 Dec 2008 21:50:58 -0000	1.17
@@ -9,6 +9,7 @@
 URL:              http://www.mirbsd.de/%{name}/
 Source0:          http://www.mirbsd.org/MirOS/dist/mir/%{name}/%{name}-R%{version}.cpio.gz
 Source1:          http://www.mirbsd.org/MirOS/dist/hosted/other/arc4random.c
+Patch:            mksh-36-alias.patch
 Requires(post):   grep
 Requires(postun): coreutils, grep
 BuildRequires:    util-linux, ed
@@ -28,6 +29,7 @@
 gzip -dc %{SOURCE0} | cpio -imd
 mv %{name}/* . && rm -rf %{name}
 cp -f %{SOURCE1} .
+%patch -p1 -b .alias
 
 %build
 CFLAGS="$RPM_OPT_FLAGS" sh Build.sh -r -j
@@ -71,6 +73,9 @@
 %{_mandir}/man1/%{name}.1*
 
 %changelog
+* Tue Dec 02 2008 Robert Scheck <robert at fedoraproject.org> 36-2
+- Upstream patch for command hang/high cpu workload (#474115)
+
 * Sat Oct 25 2008 Robert Scheck <robert at fedoraproject.org> 36-1
 - Upgrade to 36
 




More information about the fedora-extras-commits mailing list