Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Nov 2012 13:33:48 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r242766 - head/bin/sh
Message-ID:  <201211081333.qA8DXmoU081050@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Thu Nov  8 13:33:48 2012
New Revision: 242766
URL: http://svnweb.freebsd.org/changeset/base/242766

Log:
  sh: Fix two issues when an alias is redefined:
  
   * The last character is not displayed.
   * If the alias ends with itself (as a word), an infinite memory-eating loop
     occurs.
  
  If an alias is defined initially, a space is appended to avoid recursion but
  this did not happen when an alias was later modified.
  
  PR:		bin/173418
  Submitted by:	Daniel F.
  MFC after:	1 week

Modified:
  head/bin/sh/alias.c

Modified: head/bin/sh/alias.c
==============================================================================
--- head/bin/sh/alias.c	Thu Nov  8 13:06:44 2012	(r242765)
+++ head/bin/sh/alias.c	Thu Nov  8 13:33:48 2012	(r242766)
@@ -68,7 +68,18 @@ setalias(const char *name, const char *v
 		if (equal(name, ap->name)) {
 			INTOFF;
 			ckfree(ap->val);
+			/* See HACK below. */
+#ifdef notyet
 			ap->val	= savestr(val);
+#else
+			{
+			size_t len = strlen(val);
+			ap->val = ckmalloc(len + 2);
+			memcpy(ap->val, val, len);
+			ap->val[len] = ' ';
+			ap->val[len+1] = '\0';
+			}
+#endif
 			INTON;
 			return;
 		}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201211081333.qA8DXmoU081050>