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 f8f2c4b608 Remove obsolete quote balancing hack
The old Bourne shell failed to check for closing quotes and command
substitution backticks when encountering end-of-file in a parser
context (such as a script). ksh93 implemented a hack for partial
compatibility with this bug, tolerating unbalanced quotes and
backticks in backtick command subsitutions, 'eval', and command
line invocation '-c' scripts only.

This hack became broken for backtick command substitutions in
fe20311f/350b52ea as a memory leak was fixed by adding a newline to
the stack at the end of the command substitution. That extra
newline becomes part of any string whose quotes are not properly
terminated, causing problems such as the one detailed here:
https://www.mail-archive.com/ast-developers@lists.research.att.com/msg01889.html

    $ touch abc
    $ echo `ls "abc`
    ls: abc
    : not found

No other fix for the memory leak is known that doesn't cause other
problems. (The alternative fix detailed in the referenced mailing
list post causes a different corner-case regression.)

Besides, the hack has always caused other corner case bugs as well:

	$ ksh -c '((i++'
Actual:	ksh: i++(: not found
	(If an external command 'i++(' existed, it would be run)
Expect:	ksh: syntax error at line 1: `(' unmatched

	$ ksh -c 'i=0; echo $((++i'
Actual:	(empty line; the arithmetic expansion is ignored)
Expect:	ksh: syntax error at line 1: `(' unmatched

	$ ksh -c 'echo $(echo "hi)'
Actual:	ksh: syntax error at line 1: `(' unmatched
Expect: ksh: syntax error at line 1: `"' unmatched

So, it's time to get rid of this hack. The old Bourne shell is
dead and buried. No other shell tries to support this breakage.
Tolerating syntax errors is just asking for strange side effects,
inconsistent states, and corner case bugs. We should not want to do
that. Old scripts that rely on this will just need to be fixed.

src/cmd/ksh93/sh/lex.c:
- struct lexdata: Remove 'char balance' member for remembering an
  unbalanced quote or backtick.
- sh_lex(): Remove the back to remember and compensate for
  unbalanced quotes/backticks that was executed only if we were
  executing a script from a string, as opposed to a file.

src/cmd/ksh93/COMPATIBILITY:
- Note the change.

Resolves: https://github.com/ksh93/ksh/issues/199
2021-03-05 22:17:14 +00:00
..
args.c Add more out of memory checks (re: 18529b88) (#192) 2021-02-27 21:21:58 +00:00
arith.c Fix arbitrary command execution vuln in array subscripts in arith 2021-03-04 13:37:13 +00:00
array.c Fix arbitrary command execution vuln in array subscripts in arith 2021-03-04 13:37:13 +00:00
defs.c test/[: use a shell state bit (re: 7003aba4) 2020-08-30 05:33:59 +01:00
deparse.c Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
expand.c Fix many compiler warnings and remove unused variables (#191) 2021-02-22 22:16:32 +00:00
fault.c Add more out of memory checks (re: 18529b88) (#192) 2021-02-27 21:21:58 +00:00
fcin.c Fix parsing of multibyte characters 2020-06-12 01:45:17 +02:00
init.c Fix compiling with SHOPT_REGRESS and SHOPT_P_SUID 2021-02-28 23:24:58 +00:00
io.c Add more out of memory checks (re: 18529b88) (#192) 2021-02-27 21:21:58 +00:00
jobs.c Add more out of memory checks (re: 18529b88) (#192) 2021-02-27 21:21:58 +00:00
lex.c Remove obsolete quote balancing hack 2021-03-05 22:17:14 +00:00
macro.c Add more out of memory checks (re: 18529b88) (#192) 2021-02-27 21:21:58 +00:00
main.c Add more out of memory checks (re: 18529b88) (#192) 2021-02-27 21:21:58 +00:00
name.c Add more out of memory checks (re: 18529b88) (#192) 2021-02-27 21:21:58 +00:00
nvdisc.c Add more out of memory checks (re: 18529b88) (#192) 2021-02-27 21:21:58 +00:00
nvtree.c Add more out of memory checks (re: 18529b88) (#192) 2021-02-27 21:21:58 +00:00
nvtype.c Add more out of memory checks (re: 18529b88) (#192) 2021-02-27 21:21:58 +00:00
parse.c Add more out of memory checks (re: 18529b88) (#192) 2021-02-27 21:21:58 +00:00
path.c Add more out of memory checks (re: 18529b88) (#192) 2021-02-27 21:21:58 +00:00
pmain.c Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
shcomp.c resolve/remove USAGE_LICENSE macros; remove repetitive (c) strings 2021-01-31 11:00:49 +00:00
streval.c silence macro redefinition warnings (re: 7003aba4) 2020-06-16 04:51:21 +02:00
string.c Fix garbled output from Ctrl+Alt+V (#135) 2020-09-25 03:37:22 +01:00
subshell.c Add more out of memory checks (re: 18529b88) (#192) 2021-02-27 21:21:58 +00:00
suid_exec.c Add lots of checks for out of memory (re: 0ce0b671) 2021-02-21 22:27:28 +00:00
tdump.c Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
timers.c Add more out of memory checks (re: 18529b88) (#192) 2021-02-27 21:21:58 +00:00
trestore.c '#if 0' cleanup 2020-08-30 04:51:20 +01:00
waitevent.c Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
xec.c Add more out of memory checks (re: 18529b88) (#192) 2021-02-27 21:21:58 +00:00