1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

path_pwd(): Fix use after free (re: 11177d44)

Of course, we should not free the 'cp' pointer when we still need
to use it.

Resolves: https://github.com/ksh93/ksh/issues/467
Thanks to @atheik for the report.
This commit is contained in:
Martijn Dekker 2022-02-19 21:45:01 +01:00
parent f43bb4981f
commit bc6c5dbdd9
2 changed files with 13 additions and 4 deletions

View file

@ -944,6 +944,15 @@ cd "$tmp/testdir"
wait "$!" 2>/dev/null
((!(e = $?))) || err_exit 'shell crashes on failure obtain the PWD on init' \
"(got status $e$( ((e>128)) && print -n /SIG && kill -l "$e"))"
cd "$tmp"
# ======
# https://github.com/ksh93/ksh/issues/467
[[ -d emptydir ]] || mkdir emptydir
got=$(unset PWD; "$SHELL" -c 'echo "$PWD"; pwd; cd emptydir' 2>&1)
exp=$PWD$'\n'$PWD
[[ $got == "$exp" ]] || err_exit "child shell failed to obtain PWD" \
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
# ======
exit $((Errors<125?Errors:125))