1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00
cde/src/cmd/ksh93/sh
Martijn Dekker e6d0187dd8 Don't allow 'enum' and 'typeset -T' to override special built-ins
Special builtins are undeleteable for a reason. But 'enum' and
'typeset -T' allow overriding them, causing an inconsistent state.

@JohnoKing writes:
| The behavior is rather buggy, as it appears to successfully
| override normal builtins but fails to delete the special
| builtins, leading to scenarios where both the original builtin
| and type are run:
|
| $ typeset -T eval=(typeset BAD; typeset TYPE)  # This should have failed
| $ eval foo=BAD
| /usr/bin/ksh: eval: line 1: foo: not found
| $ enum trap=(BAD TYPE)   # This also should have failed
| $ trap foo=BAD
| /usr/bin/ksh: trap: condition(s) required
| $ enum umask=(BAD TYPE)
| $ umask foo=BAD
| $ echo $foo
| BAD
|
| # Examples of general bugginess
| $ trap bar=TYPE
| /usr/bin/ksh: trap: condition(s) required
| $ echo $bar
| TYPE
| $ eval var=TYPE
| /usr/bin/ksh: eval: line 1: var: not found
| $ echo $var
| TYPE

This commit fixes the following:

The 'enum' and 'typeset -T' commands are no longer allowed to
override and replace special built-in commands, except for type
definition commands previously created by these commands; these
are already (dis)allowed elsewhere.

A command like 'typeset -T foo_t' without any assignments no longer
creates an incompletely defined 'foo_t' built-in comamnd. Instead,
it is now silently ignored for backwards compatibility. This did
have a regression test checking for it, but I'm changing it because
that's just not a valid use case. An incomplete type definition
command does nothing useful and only crashes the shell when run.

src/cmd/ksh93/bltins/enum.c: b_enum():
- Do not allow overriding non-type special built-ins.

src/cmd/ksh93/sh/name.c: nv_setlist():
- Do not allow 'typeset -T' to override non-type special built-ins.
  To avoid an inconsistent state, this must be checked for while
  processing the assignments list before typeset is really invoked.

src/cmd/ksh93/bltins_typeset.c: b_typeset():
- Only create a type command if sh.envlist is set, i.e., if some
  shell assignment(s) were passed to the 'typeset -T' command.

Progresses: https://github.com/ksh93/ksh/issues/350
2022-02-10 21:01:00 +00:00
..
args.c Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
arith.c Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
array.c Fix conditional expansions ${array[i]=value}, ${array[i]?error} 2022-02-05 23:39:16 +00:00
defs.c [shp cleanup 00] Reunify the original sh state struct 2022-01-01 02:28:06 +00:00
deparse.c INIT: remove proto, ratz (re: 46593a89, 6137b99a); major cleanup 2021-12-24 07:05:22 +00:00
expand.c Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
fault.c trap: fix use after free (#446) 2022-02-05 13:53:11 +00:00
fcin.c INIT: remove proto, ratz (re: 46593a89, 6137b99a); major cleanup 2021-12-24 07:05:22 +00:00
init.c Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
io.c Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
jobs.c trap: fix use after free (#446) 2022-02-05 13:53:11 +00:00
lex.c Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
macro.c Fix conditional expansions ${array[i]=value}, ${array[i]?error} 2022-02-05 23:39:16 +00:00
main.c Export all variables assigned to while allexport is on (#431) 2022-02-05 13:52:28 +00:00
name.c Don't allow 'enum' and 'typeset -T' to override special built-ins 2022-02-10 21:01:00 +00:00
nvdisc.c Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
nvtree.c typeset -p: fix output of nonexistent [0]= array element (#451) 2022-02-05 13:53:51 +00:00
nvtype.c Accumulated fixes for minor issues (#442) 2022-01-30 20:42:59 +00:00
parse.c Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
path.c Support glibc 2.35's posix_spawn_file_actions_addtcsetpgrp_np(3) 2022-02-05 13:31:31 +00:00
pmain.c INIT: remove proto, ratz (re: 46593a89, 6137b99a); major cleanup 2021-12-24 07:05:22 +00:00
shcomp.c Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
streval.c Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
string.c Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
subshell.c Another round of accumulated tweaks and cleanups 2022-01-28 21:12:31 +00:00
suid_exec.c Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
tdump.c INIT: remove proto, ratz (re: 46593a89, 6137b99a); major cleanup 2021-12-24 07:05:22 +00:00
timers.c Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
trestore.c Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
waitevent.c Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
xec.c Support glibc 2.35's posix_spawn_file_actions_addtcsetpgrp_np(3) 2022-02-05 13:31:31 +00:00