From 0f7e252d5c47dee06d76308af9326d47daf9f02c Mon Sep 17 00:00:00 2001 From: zhuk Date: Fri, 5 Mar 2021 15:22:03 +0000 Subject: [PATCH] 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@ --- bin/ksh/var.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ksh/var.c b/bin/ksh/var.c index 6cfe75e456c..9dbba073166 100644 --- a/bin/ksh/var.c +++ b/bin/ksh/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 #include @@ -644,7 +644,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 -- 2.20.1