Module Name:    src
Committed By:   kre
Date:           Sun Dec  2 10:27:58 UTC 2018

Modified Files:
        src/bin/sh: alias.c

Log Message:
Fix the worst of the bugs in alias processing.   This has been in sh
since this code was first imported (May 1994) (ie: before 4.4-Lite)

There is (much) more coming soon (the big ugly comment is going away).

This one has been separated out, as it can easily cause sh
core dumps, so needs:

XXX pullup-8

(the other changes to aliases probably will not get that.)


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/bin/sh/alias.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/sh/alias.c
diff -u src/bin/sh/alias.c:1.18 src/bin/sh/alias.c:1.19
--- src/bin/sh/alias.c:1.18	Sat Dec  1 01:20:05 2018
+++ src/bin/sh/alias.c	Sun Dec  2 10:27:58 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: alias.c,v 1.18 2018/12/01 01:20:05 kre Exp $	*/
+/*	$NetBSD: alias.c,v 1.19 2018/12/02 10:27:58 kre Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)alias.c	8.3 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: alias.c,v 1.18 2018/12/01 01:20:05 kre Exp $");
+__RCSID("$NetBSD: alias.c,v 1.19 2018/12/02 10:27:58 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -69,17 +69,9 @@ setalias(char *name, char *val)
 {
 	struct alias *ap, **app;
 
+	(void) unalias(name);	/* old one (if any) is now gone */
 	app = hashalias(name);
-	for (ap = *app; ap; ap = ap->next) {
-		if (equal(name, ap->name)) {
-			INTOFF;
-			ckfree(ap->val);
-			ap->val	= savestr(val);
-			INTON;
-			return;
-		}
-	}
-	/* not found */
+
 	INTOFF;
 	ap = ckmalloc(sizeof (struct alias));
 	ap->name = savestr(name);

Reply via email to