mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
The following set of commands caused ksh to crash: $ unalias history; unalias r Memory fault When ksh is compiled with -D_std_malloc, the crash always occurs when the 'r' alias is removed with 'unalias r', although with vmalloc 'unalias history' must be run first for the crash to occur. With the native malloc, the crash message is also different: $ unalias history; unalias r free(): invalid pointer Abort This crash happens because when an alias is unset, _nv_unset removes the NV_NOFREE flag which results in an invalid use of free(3) as nv_isattr no longer detects NV_NOFREE afterward. The history and r aliases shouldn't be freed from memory by nv_delete because those aliases are given the NV_NOFREE attribute. src/cmd/ksh93/bltins/typeset.c: - Save the state of NV_NOFREE for aliases to fix the crash caused by 'unalias r'. src/cmd/ksh93/tests/alias.sh: - Use unalias on both history and r to check for the crash. 'unalias -a' can't be used to replicate the crash. Co-authored-by: Martijn Dekker <martijn@inlv.org>
This commit is contained in:
parent
7e5fd3e98d
commit
7e7f137245
2 changed files with 13 additions and 5 deletions
|
@ -109,9 +109,9 @@ alias foo=bar
|
|||
unalias foo
|
||||
unalias foo && err_exit 'unalias should return non-zero when a previously set alias is unaliased twice'
|
||||
|
||||
# Removing a preset alias should work without an error from free(3)
|
||||
err=$(set +x; { "$SHELL" -i -c 'unalias history'; } 2>&1) && [[ -z $err ]] \
|
||||
|| err_exit "removing a preset alias does not work (got $(printf %q "$err"))"
|
||||
# Removing the history and r aliases should work without an error from free(3)
|
||||
err=$(set +x; { "$SHELL" -i -c 'unalias history; unalias r'; } 2>&1) && [[ -z $err ]] \
|
||||
|| err_exit "the 'history' and 'r' aliases can't be removed (got $(printf %q "$err"))"
|
||||
|
||||
# ======
|
||||
exit $((Errors<125?Errors:125))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue