oksh-noxz

[fork] Portable OpenBSD ksh, based on the Public Domain Korn Shell (pdksh).
git clone https://noxz.tech/git/oksh-noxz.git
oksh-noxz

commit: 27efeb20ba7f7ae11d0f94215bc3bf36f04cc080
parent: 5686a43a94dfe6a1217256a6d99991a0323f5f18
author: Brian Callahan <bcallah@openbsd.org>
date:   Sat, 6 Mar 2021 11:38:20 -0500
Update to latest OpenBSD code.

CVSROOT:	/cvs
Module name:	src
Changes by:	zhuk@cvs.openbsd.org	2021/03/05 08:22:03

Modified files:
	bin/ksh        : var.c

Log message:
Fix old ksh bug: wrong variable being looked up when value is provided.

This results, e.g., in allowing the first item of a read-only array to
be overwritten, as found by Jordan Geoghegan.

okay tb@
MCVS/Entries62++++++++++----------
Mvar.c4+-
2 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/CVS/Entries b/CVS/Entries
@@ -7,40 +7,40 @@
 /io.c/1.38/Result of merge//
 /history.c/1.84/Result of merge//
 /trap.c/1.33/Tue Dec 17 00:39:35 2019//
-/var.c/1.71/Result of merge//
 /emacs.c/1.87/Result of merge//
 /sh.h/1.76/Result of merge//
 /eval.c/1.66/Result of merge//
 /misc.c/1.76/Result of merge//
 /vi.c/1.57/Sat Oct 31 00:41:35 2020//
-/CONTRIBUTORS/1.11/Wed Feb 10 02:59:56 2021//
-/LEGAL/1.2/Wed Feb 10 02:59:56 2021//
-/Makefile/1.39/Wed Feb 10 03:00:14 2021//
-/NOTES/1.16/Wed Feb 10 02:59:56 2021//
-/PROJECTS/1.9/Wed Feb 10 02:59:56 2021//
-/README/1.16/Wed Feb 10 03:00:14 2021//
-/alloc.c/1.19/Wed Feb 10 02:59:56 2021//
-/c_ksh.c/1.62/Wed Feb 10 02:59:56 2021//
-/c_sh.c/1.64/Wed Feb 10 02:59:56 2021//
-/c_test.h/1.4/Wed Feb 10 02:59:56 2021//
-/c_ulimit.c/1.29/Wed Feb 10 02:59:56 2021//
-/edit.h/1.12/Wed Feb 10 02:59:56 2021//
-/expand.h/1.15/Wed Feb 10 02:59:56 2021//
-/expr.c/1.34/Wed Feb 10 02:59:56 2021//
-/jobs.c/1.62/Wed Feb 10 02:59:56 2021//
-/ksh.1/1.210/Wed Feb 10 02:59:56 2021//
-/lex.c/1.78/Wed Feb 10 02:59:56 2021//
-/lex.h/1.21/Wed Feb 10 02:59:56 2021//
-/mail.c/1.27/Wed Feb 10 02:59:56 2021//
-/path.c/1.23/Wed Feb 10 02:59:56 2021//
-/sh.1/1.152/Wed Feb 10 02:59:56 2021//
-/shf.c/1.34/Wed Feb 10 02:59:56 2021//
-/shf.h/1.8/Wed Feb 10 02:59:56 2021//
-/syn.c/1.39/Wed Feb 10 02:59:56 2021//
-/table.c/1.25/Wed Feb 10 02:59:56 2021//
-/table.h/1.15/Wed Feb 10 02:59:56 2021//
-/tree.c/1.34/Wed Feb 10 02:59:56 2021//
-/tree.h/1.12/Wed Feb 10 02:59:56 2021//
-/tty.h/1.6/Wed Feb 10 02:59:56 2021//
-/version.c/1.12/Wed Feb 10 02:59:56 2021//
+/CONTRIBUTORS/1.11/Sat Mar  6 16:35:13 2021//
+/LEGAL/1.2/Sat Mar  6 16:35:13 2021//
+/Makefile/1.39/Sat Mar  6 16:35:19 2021//
+/NOTES/1.16/Sat Mar  6 16:35:13 2021//
+/PROJECTS/1.9/Sat Mar  6 16:35:13 2021//
+/README/1.16/Sat Mar  6 16:35:19 2021//
+/alloc.c/1.19/Sat Mar  6 16:35:13 2021//
+/c_ksh.c/1.62/Sat Mar  6 16:35:13 2021//
+/c_sh.c/1.64/Sat Mar  6 16:35:13 2021//
+/c_test.h/1.4/Sat Mar  6 16:35:13 2021//
+/c_ulimit.c/1.29/Sat Mar  6 16:35:13 2021//
+/edit.h/1.12/Sat Mar  6 16:35:13 2021//
+/expand.h/1.15/Sat Mar  6 16:35:13 2021//
+/expr.c/1.34/Sat Mar  6 16:35:13 2021//
+/jobs.c/1.62/Sat Mar  6 16:35:13 2021//
+/ksh.1/1.210/Sat Mar  6 16:35:13 2021//
+/lex.c/1.78/Sat Mar  6 16:35:13 2021//
+/lex.h/1.21/Sat Mar  6 16:35:13 2021//
+/mail.c/1.27/Sat Mar  6 16:35:13 2021//
+/path.c/1.23/Sat Mar  6 16:35:13 2021//
+/sh.1/1.152/Sat Mar  6 16:35:13 2021//
+/shf.c/1.34/Sat Mar  6 16:35:13 2021//
+/shf.h/1.8/Sat Mar  6 16:35:13 2021//
+/syn.c/1.39/Sat Mar  6 16:35:13 2021//
+/table.c/1.25/Sat Mar  6 16:35:13 2021//
+/table.h/1.15/Sat Mar  6 16:35:13 2021//
+/tree.c/1.34/Sat Mar  6 16:35:13 2021//
+/tree.h/1.12/Sat Mar  6 16:35:13 2021//
+/tty.h/1.6/Sat Mar  6 16:35:13 2021//
+/var.c/1.72/Result of merge//
+/version.c/1.12/Sat Mar  6 16:35:13 2021//
 D
diff --git a/var.c b/var.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: var.c,v 1.71 2020/02/21 18:21:23 tb Exp $	*/
+/*	$OpenBSD: var.c,v 1.72 2021/03/05 15:22:03 zhuk Exp $	*/
 
 #include <sys/stat.h>
 #include <sys/time.h>
@@ -653,7 +653,7 @@ typeset(const char *var, int set, int clr, int field, int base)
 	    global(tvar);
 	set &= ~(LOCAL|LOCAL_COPY);
 
-	vpbase = (vp->flag & ARRAY) ? global(arrayname(var)) : vp;
+	vpbase = (vp->flag & ARRAY) ? global(arrayname(tvar)) : vp;
 
 	/* only allow export flag to be set.  at&t ksh allows any attribute to
 	 * be changed, which means it can be truncated or modified