mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
lex.c: prevent restoring outdated stack pointer
Lexical levels are stored in a dynamically grown array of int values grown by the stack_grow function. The pointer lex_match and the maximum index lex_max are part of the lexer state struct that is now saved and restored in various places -- see e.g.37044047
,a2bc49be
. If the stack needs to be grown, it is reallocated in stack_grow() using sh_realloc(). If that happens between saving and restoring the lexer state, then an outdated pointer is restored, and crash. src/cmd/ksh93/include/shlex.h, src/cmd/ksh93/sh/lex.c: - Take lex_match and lex_max out of the lexer state struct and make them separate static variables. src/cmd/ksh93/edit/edit.c: - While we're at it, save and restore the lexer state in a way that is saner than the 93v- beta approach (re:37044047
) as well as more readable. Instead of permanently allocating memory, use a local variable to save the struct. Save/restore directly around the sh_trap() call that actually needs this done. Resolves: https://github.com/ksh93/ksh/issues/482
This commit is contained in:
parent
d8dc2a1d81
commit
da97587e9e
4 changed files with 17 additions and 20 deletions
2
NEWS
2
NEWS
|
@ -8,6 +8,8 @@ Any uppercase BUG_* names are modernish shell bug IDs.
|
|||
- Fixed: 'echo' failed when used inside a command substitution that
|
||||
is inside a nested compound assignment.
|
||||
|
||||
- Fixed a crash in KEYBD trap handling introduced on 2021-11-29.
|
||||
|
||||
2022-06-20:
|
||||
|
||||
- Fixed a race condition that could cause redirections to fail with a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue