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/include
Johnothan King 113a9392ff
Fix vi mode crashes when going back one word (#246)
This bug was originally reported at <https://github.com/att/ast/issues/1467>.
A crash can occur when using the 'b' or 'B' vi mode commands to go back
one word. I was able to reproduce these crashes with 100% consistency on
an OpenBSD virtual machine when ksh is compiled with -D_std_malloc.
Reproducer:
    $ set -o vi
    $ asdf <ESC> <b or B>

The fix is based on Matthew DeVore's analysis:
> I suspect this is caused by this line:
>> while (vi_isalph(tcur_virt) && tcur_virt >= first_virt) --tcur_virt;
> which is in the b codepath. It checks vi_isalph(tcur_virt) before checking
> if tcur_virt is in range. These two clauses should be reversed. Note that
> line 316 is a similar check for pressing B, and there the tcur_virt value
> is checked first.

src/cmd/ksh93/edit/vi.c:
- Check tcur_virt before using isalph() or isblank() to fix both crashes.
  At the start of the backword() while loop this check was performed
  twice, so the redundant check has been removed.

src/cmd/ksh93/tests/pty.sh:
- Add a regression test for the b, B, w and W editor commands.
2021-03-30 11:25:20 +01:00
..
argnod.h Fix bugs related to --posix shell option (re: 921bbcae, f45a0f16) 2021-02-14 23:51:19 +00:00
builtins.h Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
defs.h Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
edit.h Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
fault.h Remove legacy code for older libast versions 2020-09-04 02:31:39 +02:00
fcin.h Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
history.h Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
io.h Remove more legacy libast code (re: f9c127e3, 651bbd56) 2021-03-21 06:39:32 +00:00
jobs.h Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
lexstates.h Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
name.h Fix set/unset state for short integer (typeset -si) (#211) 2021-03-08 04:19:36 +00:00
national.h Fix compile/regress fails on compiling without SHOPT_* options 2021-02-08 22:02:45 +00:00
nval.h Fix floating point numerics having precision of 0 with assignments (#149) 2020-11-26 13:50:30 +00:00
path.h cleanup: remove legacy code for systems without fork(2) 2021-03-21 06:39:32 +00:00
regress.h Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
shell.h cleanup: fix redundant NOT_USED macro redefinition (re: 733f70e9) 2021-03-23 02:44:01 +00:00
shlex.h Fix various minor problems and update the documentation (#237) 2021-03-21 14:39:03 +00:00
shnodes.h Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
shtable.h tests/options.sh: add forgotten SHOPT_BRACEPAT check (re: af5f7acf) 2021-02-15 01:57:17 +00:00
streval.h Remove legacy code for older libast versions 2020-09-04 02:31:39 +02:00
terminal.h Fixes for implicit declaration warnings 2020-06-14 09:55:08 -04:00
test.h test foo =~ foo should fail with exit status 2 (#245) 2021-03-27 21:51:16 +00:00
timeout.h Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
ulimit.h sh_setmatch(): fix node size calculation 2021-02-02 11:52:54 +00:00
variables.h Allow proper tilde expansion overrides (#225) 2021-03-17 21:07:14 +00:00
version.h Fix vi mode crashes when going back one word (#246) 2021-03-30 11:25:20 +01:00