svn commit: r242766 - head/bin/sh
Jilles Tjoelker
jilles at FreeBSD.org
Thu Nov 8 13:33:49 UTC 2012
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;
}
More information about the svn-src-head
mailing list