summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2012-11-08 13:33:48 +0000
committerjilles <jilles@FreeBSD.org>2012-11-08 13:33:48 +0000
commit9009053e85b7e80aa70a82c20f8d2b839c965221 (patch)
tree33f536d735cd77d85d1c61f9030b9e58ef639d91 /bin
parent746fc5fdeedd50a411bb58ddcb54f5cedb89876a (diff)
downloadFreeBSD-src-9009053e85b7e80aa70a82c20f8d2b839c965221.zip
FreeBSD-src-9009053e85b7e80aa70a82c20f8d2b839c965221.tar.gz
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
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/alias.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/bin/sh/alias.c b/bin/sh/alias.c
index fb0e922..da995bb 100644
--- a/bin/sh/alias.c
+++ b/bin/sh/alias.c
@@ -68,7 +68,18 @@ setalias(const char *name, const char *val)
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;
}
OpenPOWER on IntegriCloud