>Number: 173418
>Category: bin
>Synopsis: /bin/sh - Alias breaks if set twice.
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Tue Nov 06 10:20:01 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator: Daniel F.
>Release: 9.0-RELEASE i386
>Organization:
>Environment:
FreeBSD freebsd 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:15:25 UTC
2012 [email protected]:/usr/obj/usr/src/sys/GENERIC i386
>Description:
Function setalias() in alias.c of bin/sh uses a hack to avoid alias recursion
by appending a single space character to alias value. This does not happen when
we're redefining already existing alias.
When we execute or view aliases, the last character gets stripped in order to
get rid of the extra space. In case of redefined alias this will become a
problem.
>How-To-Repeat:
$/bin/sh
$alias a=b
$alias a=b
$alias
Or by sourcing a file with alias definitions, twice.
>Fix:
Use the hack in part of code where it checks if alias already exists.
Patch attached with submission follows:
--- alias.c.orig 2012-11-05 21:49:57.000000000 +0200
+++ alias.c 2012-11-05 21:50:03.000000000 +0200
@@ -68,7 +68,17 @@
if (equal(name, ap->name)) {
INTOFF;
ckfree(ap->val);
+#ifdef notyet
ap->val = savestr(val);
+#else
+ {
+ size_t vlen = strlen(val);
+ ap->val = ckmalloc(vlen + 2);
+ memcpy(ap->val, val, vlen);
+ ap->val[vlen] = ' ';
+ ap->val[vlen+1] = '\0';
+ }
+#endif
INTON;
return;
}
>Release-Note:
>Audit-Trail:
>Unformatted:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"