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/sh
Martijn Dekker 7bab9508aa Fix crash on subshell exit if PWD is inaccessible (re: dd9bc229)
This commit also further mitigates the problems with restoring an
inaccessible or nonexistent PWD on exiting a virtual subshell.

Harald van Dijk writes:
> On a build of ksh with -fsanitize=undefined to help diagnose
> problems:
>
> $ mkdir deleted
> $ cd deleted
> $ rmdir ../deleted
> $ ksh -c '(cd /; (cd /)); :'
> /home/harald/ksh/src/cmd/ksh93/sh/subshell.c:561:22: runtime
> error: null pointer passed as argument 1, which is declared to
> never be null
> Segmentation fault (core dumped)
>
> Note that it segfaults the same with default compilation flags,
> but it does not print out the useful extra message. The code
> assumes that pwd is non-null and passes it to strcmp without
> checking, but it will be null if the current directory cannot be
> determined, for instance because it has been deleted.

src/cmd/ksh93/sh/subshell.c: sh_subshell():
- Avoid the null pointer dereference reported above.

src/cmd/ksh93/bltins/cd_pwd.c: b_cd():
- Fork a virtual subshell even on systems with fchdir(2) if the
  present working directory tests as inaccessible on invoking 'cd';
  it may no longer exist and fchdir would fail to get a handle.
  (For the test we have to opendir(3) the full path to the PWD and
  not ".", as the latter may succeed even if the PWD is gone.)

src/cmd/ksh93/data/builtins.c:
- Update 'cd' version string.

Fixes:   https://github.com/ksh93/ksh/issues/153
Related: https://github.com/ksh93/ksh/issues/141
2021-01-19 18:47:41 +00:00
..
args.c Streamline some shell state flaggery 2020-10-02 23:58:21 +02:00
arith.c Arith: informative err msg on '.' radix point in non-'.' locales 2021-01-05 23:16:53 +00:00
array.c Fix several memory leaks related to arrays (rhbz#921455) 2020-09-15 07:47:38 +02: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 Remove legacy code for older libast versions 2020-09-04 02:31:39 +02:00
fault.c Fix SIGHUP on termination (Solaris patch 260-22964338) 2021-01-08 17:33:04 +00:00
fcin.c Fix parsing of multibyte characters 2020-06-12 01:45:17 +02:00
init.c sh_init(): rm directoryless '.profile' login file path 2021-01-08 23:53:04 +00:00
io.c Replace safe FD fix with Solaris/ksh2020 version (re: 045fe6a1) 2021-01-08 16:35:26 +00:00
jobs.c job_unpost(): fix segfault 2021-01-18 07:14:06 +00:00
lex.c Fix lexing of 'case' in do...done in a $(comsub) (rhbz#1241013) 2020-09-27 21:26:09 +02:00
macro.c Fix for memory mgmt in variable expansion (Solaris 105-CR7032068) 2021-01-09 00:28:11 +00:00
main.c sh_main(): do not decrease null pointer 2021-01-19 18:39:43 +00:00
name.c nv_newattr(): fix potential invalid free 2021-01-17 03:55:46 +00:00
nvdisc.c setdisc(): Return null pointer if no event (Solaris 110-CR7061011) 2021-01-08 11:27:30 +00:00
nvtree.c '#if 0' cleanup 2020-08-30 04:51:20 +01:00
nvtype.c Fix off-by-one in nv_mktype() (Solaris patch 210-Bug15993811) 2021-01-08 11:56:04 +00:00
parse.c Fix 'command' expansion bug and POSIX compliance 2020-09-11 10:06:43 +02:00
path.c Implement hash tables for virtual subshells (re: 102868f8, 9d428f8f) 2021-01-07 22:18:25 +00:00
pmain.c Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
shcomp.c Version: 2012-08-01-master 2016-01-11 15:54:23 -05: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 Fix crash on subshell exit if PWD is inaccessible (re: dd9bc229) 2021-01-19 18:47:41 +00:00
suid_exec.c rm redundant getpid(2) syscalls (re: 9de65210) 2020-09-23 04:19:02 +02:00
tdump.c Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
timers.c rm redundant getpid(2) syscalls (re: 9de65210) 2020-09-23 04:19:02 +02: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 Revert "Fix SIGALRM core dump (Solaris patch 230-18229654)" 2021-01-09 13:18:00 +00:00