rpms/mksh/F-13 mksh-39c-dblalias.patch, NONE, 1.1 mksh-39c-fixsetx.patch, NONE, 1.1 mksh.spec, 1.28, 1.29

Michal Hlavinka mhlavink at fedoraproject.org
Wed Jul 21 14:07:15 UTC 2010


Author: mhlavink

Update of /cvs/pkgs/rpms/mksh/F-13
In directory cvs01.phx2.fedoraproject.org:/tmp/cvs-serv13981

Modified Files:
	mksh.spec 
Added Files:
	mksh-39c-dblalias.patch mksh-39c-fixsetx.patch 
Log Message:
* Wed Jul 21 2010 Michal Hlavinka <mhlavink at redhat.com> 39c-2
- fix crash when alias contains alias
- fix crash when xtrace is enabled


mksh-39c-dblalias.patch:
 check.t |   11 +++++++++++
 lex.c   |    2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

--- NEW FILE mksh-39c-dblalias.patch ---
--- a/check.t	2010/07/19 22:41:01	1.383
+++ b/check.t	2010/07/21 11:31:13	1.384
@@ -184,6 +184,17 @@ stdin:
 expected-stdout:
 	tf
 	tf
+---
+name: alias-10
+description:
+	Check that recursion is detected/avoided in aliases.
+	Regression, introduced during an old bugfix.
+stdin:
+	alias foo='print hello '
+	alias bar='foo world'
+	echo $(bar)
+expected-stdout:
+	hello world
 ---
 name: arith-lazy-1
 description:
--- a/lex.c	2010/07/17 22:09:36	1.116
+++ b/lex.c	2010/07/21 11:31:15	1.117
@@ -1110,7 +1110,7 @@ yylex(int cf)
 			else {
 				Source *s = source;
 
-				while (s->flags & SF_HASALIAS)
+				while (s && (s->flags & SF_HASALIAS))
 					if (s->u.tblp == p)
 						return (LWORD);
 					else

mksh-39c-fixsetx.patch:
 shf.c |   55 ++++++++++++++++++++++++++++++++++---------------------
 1 file changed, 34 insertions(+), 21 deletions(-)

--- NEW FILE mksh-39c-fixsetx.patch ---
--- old/shf.c	2009/11/28 14:28:03	1.35
+++ new/shf.c	2010/07/19 22:41:04	1.36
@@ -636,32 +636,45 @@ shf_write(const char *buf, int nbytes, s
 		shf->wnleft -= ncopy;
 	}
 	if (nbytes > 0) {
-		/* Flush deals with strings and sticky errors */
-		if (shf_emptybuf(shf, EB_GROW) == EOF)
-			return (EOF);
-		if (nbytes > shf->wbsize) {
-			ncopy = nbytes;
-			if (shf->wbsize)
-				ncopy -= nbytes % shf->wbsize;
-			nbytes -= ncopy;
-			while (ncopy > 0) {
-				n = write(shf->fd, buf, ncopy);
-				if (n < 0) {
-					if (errno == EINTR &&
-					    !(shf->flags & SHF_INTERRUPT))
-						continue;
-					shf->flags |= SHF_ERROR;
-					shf->errno_ = errno;
-					shf->wnleft = 0;
-					/* Note: fwrite(3S) returns 0 for
-					 * errors - this doesn't */
+		if (shf->flags & SHF_STRING) {
+			/* resize buffer until there's enough space left */
+			while (nbytes > shf->wnleft)
+				if (shf_emptybuf(shf, EB_GROW) == EOF)
 					return (EOF);
+			/* then write everything into the buffer */
+		} else {
+			/* flush deals with sticky errors */
+			if (shf_emptybuf(shf, EB_GROW) == EOF)
+				return (EOF);
+			/* write chunks larger than window size directly */
+			if (nbytes > shf->wbsize) {
+				ncopy = nbytes;
+				if (shf->wbsize)
+					ncopy -= nbytes % shf->wbsize;
+				nbytes -= ncopy;
+				while (ncopy > 0) {
+					n = write(shf->fd, buf, ncopy);
+					if (n < 0) {
+						if (errno == EINTR &&
+						    !(shf->flags & SHF_INTERRUPT))
+							continue;
+						shf->flags |= SHF_ERROR;
+						shf->errno_ = errno;
+						shf->wnleft = 0;
+						/*
+						 * Note: fwrite(3) returns 0
+						 * for errors - this doesn't
+						 */
+						return (EOF);
+					}
+					buf += n;
+					ncopy -= n;
 				}
-				buf += n;
-				ncopy -= n;
 			}
+			/* ... and buffer the rest */
 		}
 		if (nbytes > 0) {
+			/* write remaining bytes to buffer */
 			memcpy(shf->wp, buf, nbytes);
 			shf->wp += nbytes;
 			shf->wnleft -= nbytes;


Index: mksh.spec
===================================================================
RCS file: /cvs/pkgs/rpms/mksh/F-13/mksh.spec,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -p -r1.28 -r1.29
--- mksh.spec	26 Feb 2010 23:21:57 -0000	1.28
+++ mksh.spec	21 Jul 2010 14:07:15 -0000	1.29
@@ -3,12 +3,14 @@
 Summary:          MirBSD enhanced version of the Korn Shell
 Name:             mksh
 Version:          39c
-Release:          1%{?dist}
+Release:          2%{?dist}
 License:          MirOS
 Group:            System Environment/Shells
 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
+Patch1:           mksh-39c-fixsetx.patch
+Patch2:           mksh-39c-dblalias.patch
 Requires(post):   grep
 Requires(postun): coreutils, grep
 BuildRequires:    util-linux, ed
@@ -29,6 +31,12 @@ gzip -dc %{SOURCE0} | cpio -imd
 mv %{name}/* . && rm -rf %{name}
 cp -f %{SOURCE1} .
 
+# from upstream cvs, for mksh < "R39 2010/07/19", rhbz#616771
+%patch1 -p1 -b .fixsetx
+
+# from upstream cvs, for mksh < "R39 2010/07/21", rhbz#616777
+%patch2 -p1 -b .dblalias
+
 %build
 CFLAGS="$RPM_OPT_FLAGS" sh Build.sh -r -combine
 
@@ -71,6 +79,10 @@ rm -rf $RPM_BUILD_ROOT
 %{_mandir}/man1/%{name}.1*
 
 %changelog
+* Wed Jul 21 2010 Michal Hlavinka <mhlavink at redhat.com> 39c-2
+- fix crash when alias contains alias
+- fix crash when xtrace is enabled
+
 * Sat Feb 27 2010 Robert Scheck <robert at fedoraproject.org> 39c-1
 - Upgrade to 39c and updated arc4random.c file
 



More information about the scm-commits mailing list