Author: jilles
Date: Thu Nov 22 13:50:51 2012
New Revision: 243402
URL: http://svnweb.freebsd.org/changeset/base/243402

Log:
  MFC r242766: 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.

Modified:
  stable/9/bin/sh/alias.c
Directory Properties:
  stable/9/bin/sh/   (props changed)

Modified: stable/9/bin/sh/alias.c
==============================================================================
--- stable/9/bin/sh/alias.c     Thu Nov 22 12:11:32 2012        (r243401)
+++ stable/9/bin/sh/alias.c     Thu Nov 22 13:50:51 2012        (r243402)
@@ -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;
                }
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "[email protected]"

Reply via email to