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
Johnothan King ca2443b58c
cd - shouldn't ignore $OLDPWD when in a new scope (#249)
This bug was first reported at <https://github.com/att/ast/issues/8>.
The 'cd' command currently takes the value of $OLDPWD from the
wrong scope. In the following example 'cd -' will change the
directory to /bin instead of /tmp:

    $ OLDPWD=/bin ksh93 -c 'OLDPWD=/tmp cd -'
    /bin

src/cmd/ksh93/bltins/cd_pwd.c:
- Use sh_scoped() to obtain the correct value of $OLDPWD.
- Fix a use-after-free bug. Make the 'oldpwd' variable a static
  char that points to freeable memory. Each time cd is used, this
  variable is freed if it points to a freeable memory address and
  isn't also a pointer to shp->pwd.

src/cmd/ksh93/sh/path.c: path_pwd():
- Simplify and add comments.
- Scope $PWD properly.

src/cmd/ksh93/tests/builtins.sh,
src/cmd/ksh93/tests/leaks.sh:
- Backport the ksh2020 regression tests for 'cd -' when $OLDPWD is
  set.
- Add test for $OLDPWD and $PWD after subshare.
- Add test for $PWD after 'cd'.
- Add test for possible memory leak.
- Add testing for 'unset' on OLDPWD and PWD.

src/cmd/ksh93/COMPATIBILITY:
- Add compatibility note about changes to $PWD and $OLDPWD.

Co-authored-by: Martijn Dekker <martijn@inlv.org>
2021-04-02 01:19:19 +01:00
..
args.c Fix many GCC -Wimplicit-fallthrough warnings (#243) 2021-03-30 21:49:20 +01:00
arith.c Fix arbitrary command execution vuln in array subscripts in arith 2021-03-04 13:37:13 +00:00
array.c Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
defs.c Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
deparse.c Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
expand.c Add --globcasedetect shell option for globbing and completion 2021-03-22 18:45:19 +00:00
fault.c Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
fcin.c Fix many GCC -Wimplicit-fallthrough warnings (#243) 2021-03-30 21:49:20 +01:00
init.c Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
io.c Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
jobs.c Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
lex.c Fix many GCC -Wimplicit-fallthrough warnings (#243) 2021-03-30 21:49:20 +01:00
macro.c Fix many GCC -Wimplicit-fallthrough warnings (#243) 2021-03-30 21:49:20 +01:00
main.c cleanup: remove legacy code for systems without fork(2) 2021-03-21 06:39:32 +00:00
name.c Fix many GCC -Wimplicit-fallthrough warnings (#243) 2021-03-30 21:49:20 +01:00
nvdisc.c Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
nvtree.c Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
nvtype.c Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
parse.c Fix many GCC -Wimplicit-fallthrough warnings (#243) 2021-03-30 21:49:20 +01:00
path.c cd - shouldn't ignore $OLDPWD when in a new scope (#249) 2021-04-02 01:19:19 +01: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 Fix many GCC -Wimplicit-fallthrough warnings (#243) 2021-03-30 21:49:20 +01:00
string.c Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
subshell.c Fix set/unset state for short integer (typeset -si) (#211) 2021-03-08 04:19:36 +00:00
suid_exec.c Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
tdump.c Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
timers.c Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +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 Fix many GCC -Wimplicit-fallthrough warnings (#243) 2021-03-30 21:49:20 +01:00