Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Thank you @lzaoral for debugging this issue and creating this reproducer: $ tty # check that the shell is connected to a pseudoterminal /dev/pts/4 $ mkdir /var/tmp/chroottest $ dnf --releasever=39 --installroot=/var/tmp/chroottest install ksh $ echo "/dev/udp/127.0.0.1/514;0;104" | sudo tee /var/tmp/chroottest/etc/ksh_audit $ sudo chroot /var/tmp/chroottest /bin/ksh -lic 'exit 0' (ksh segfaults) Analysis: On Linux, ttyname(3)[*] may fail if: * EBADF Bad file descriptor. * ENODEV fd refers to a slave pseudoterminal device but the corresponding pathname could not be found [...]. * ENOTTY fd does not refer to a terminal device. Calling isatty(3) before ttyname(3) only prevents the first and third cases. src/cmd/ksh93/edit/history.c: sh_histinit(): - To catch the second case, let's call ttyname(2) directly, check for NULL and remove the redundant isatty() call. [*] https://man7.org/linux/man-pages/man3/ttyname.3.html
- Loading branch information