1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-24 15:04:13 +00:00
cde/src/cmd/ksh93/edit
Johnothan King 9a9da2c299
Fix use of strdup on a NULL pointer (#63)
The following set of commands can rarely cause a memory fault
when auditing[*] is enabled, although most of the time it will
simply cause ksh to write '(null)' to the auditing file in place
of a tty name:

$ [ -e /etc/ksh_audit ] || echo "/tmp/ksh_auditfile;$(id -u)" | sudo tee /etc/ksh_audit;
$ v=$(ksh  2> /dev/null +o rc -ic $'getopts a:bc: opt --man\nprint $?')
$ cat /tmp/ksh_auditfile
1000;1593599493;(null); getopts a:bc: opt --man

This happens because strdup is used unconditionally on the pointer
returned by 'ttyname', which can be NULL if stderr is closed. This
then causes 'hp->tty' to be set to null, as strdup returns NULL.
See https://github.com/att/ast/issues/1028

src/cmd/ksh93/edit/history.c:
- Make strdup duplicate 'notty' instead of NULL to prevent
  crashes.

[*] https://blog.fpmurphy.com/2008/12/ksh93-auditing-and-accounting.html
2020-07-06 21:51:44 +01:00
..
completion.c Version: 2012-08-01-master 2016-01-11 15:54:23 -05:00
edit.c Fix behaviour of tabs in raw Bourne Shell-like editing mode 2020-06-26 11:34:02 +02:00
emacs.c Fix an issue with the up arrow key in Emacs editing mode. 2020-06-12 01:45:17 +02:00
hexpand.c Fix 80 typos in comments 2020-06-12 01:45:12 +02:00
history.c Fix use of strdup on a NULL pointer (#63) 2020-07-06 21:51:44 +01:00
vi.c Fix bugs with backslash escaping in interactive vi mode (#57) 2020-07-03 21:15:21 +02:00