1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-24 23:14:14 +00:00
cde/src/cmd/ksh93/tests
hyenias 264ba48bdd
Hardening of readonly variables (#239)
Ksh currently restricts readonly scalar variables from having their
values directly changed via a value assignment. However, since ksh
allows variable attributes to be altered, the variable's value can
be indirectly altered. For instance, if TMOUT=900 (for a 15 minute
idle timeout) was set to readonly, all that is needed to alter the
value of TMOUT from 900 to 0 is to issue 'typeset -R1 TMOUT',
perhaps followed by a 'typeset -i TMOUT' to turn off the shell's
timeout value.

In addition, there are problems with arrays. The following is
incorrectly allowed:

        typeset -a arr=((a b c) 1)
        readonly arr
        arr[0][1]=d

        arr=(alphas=(a b c);name=x)
        readonly arr.alphas
        arr.alphas[1]=([b]=5)

        arr=(alphas=(a b c);name=x)
        readonly arr.alphas
        arr.alphas[1]=(b)

        typeset -C arr=(typeset -r -a alphas=(a b c);name=x)
        arr.alphas[1]=()

src/cmd/ksh93/bltins/typeset.c: setall():
- Relocate readonly attribute check higher up the code and widen
  its application to issue an error message if the pre-existing
  name-pair has the readonly bit flag set.
- To avoid compatibility problems, don't check for readonly if
  NV_RDONLY is the only attribute set (ignoring NV_NOFREE). This
  allows 'readonly foo; readonly foo' to keep working.

src/cmd/ksh93/sh/array.c: nv_endsubscript():
- Apply a readonly flag check when an array subscript or append
  assignment occurs, but allow type variables (typeset -T) as they
  utilize '-r' for 'required' sub-variables.

src/cmd/ksh93/tests/readonly.sh:
- New file. Create readonly tests that validate the warning message
  and validate that the readonly variable did not change.

src/cmd/ksh93/sh/streval.c:
- Bump MAXLEVEL from 9 to 1024 as a workaround for arithmetic
  expansion, avoiding a spurious error about too much recursion
  when the readonly.sh tests are run. This change is backported
  from ksh 93v-.
  TODO: debug a spurious increase in arithmetic recursion level
  variable when readonly.sh tests with 'typeset -i' are run.
  That is a different bug for a different commit.

Co-authored-by: Martijn Dekker <martijn@inlv.org>
2021-04-05 06:43:19 +01:00
..
_common Fix a few regression test failures (#222) 2021-03-14 21:32:04 +00:00
alias.sh Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
append.sh Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
arith.sh Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
arrays.sh Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
arrays2.sh tests/array2.sh: fix broken tests 2021-03-30 15:38:29 +01:00
attributes.sh Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
basic.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00
bracket.sh Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
builtins.sh Fix bugs related to 'uname -d' in the 'uname' builtin (#251) 2021-04-04 22:18:43 +01:00
case.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00
comvar.sh Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
comvario.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00
coprocess.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00
cubetype.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00
enum.sh Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
exit.sh Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
expand.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00
functions.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00
glob.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00
grep.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00
heredoc.sh Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
io.sh Introduce usage of __builtin_unreachable() and noreturn (#248) 2021-04-05 00:28:24 +01:00
jobs.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00
leaks.sh cd - shouldn't ignore $OLDPWD when in a new scope (#249) 2021-04-02 01:19:19 +01:00
locale.sh Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
math.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00
nameref.sh Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
namespace.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00
options.sh Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
path.sh Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
pointtype.sh Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
pty.sh Fix vi mode crashes when going back one word (#246) 2021-03-30 11:25:20 +01:00
quoting.sh Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
quoting2.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00
readcsv.sh Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
readonly.sh Hardening of readonly variables (#239) 2021-04-05 06:43:19 +01:00
recttype.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00
restricted.sh Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
return.sh Save $? when discipline triggered without command (#226) 2021-03-16 16:13:13 +00:00
select.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00
shtests shtests: make aliases work again for shcomp tests (re: aed5c6d7) 2021-03-23 03:49:32 +00:00
sigchld.sh tests/sigchld.sh: try to fix intermittent CI fail (re: 712261c8) 2021-03-25 02:47:17 +00:00
signal.sh Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
statics.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00
subshell.sh Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
substring.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00
tilde.sh Allow proper tilde expansion overrides (#225) 2021-03-17 21:07:14 +00:00
timetype.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00
treemove.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00
types.sh Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
variables.sh tests/variables.sh: Fix locale tests (#247) 2021-03-30 14:53:08 +01:00
vartree1.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00
vartree2.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00