mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix a crash when 'read -u' is given an invalid fd (#53)
File descriptors that are too far out of range will cause the read builtin to crash. The following example will generate two crashes: $ ksh -c 'read -u 2000000' || ksh -c 'read -u-2000000' The fix is to error out when the given file descriptor is out of range. This bugfix is from Tomas Klacko, although it was modified to use 'sh_iovalidfd' and reject numbers greater than 'INT_MAX': https://www.mail-archive.com/ast-developers@lists.research.att.com/msg01912.html The question about 'shp->fdstatus[-1]' only applies to ksh93v- (ksh93u+ doesn't have any references to 'shp->fdstatus[-1]'). src/cmd/ksh93/bltins/read.c: - File descriptors that are out of range should be rejected with an error message (like invalid file descriptors that are in range). The seemingly redundant check for negative numbers is there because out of range negative numbers also cause memory faults despite the later 'fd<0' check. src/cmd/ksh93/tests/io.sh: - Add three tests for attempting 'read -u' on various invalid file descriptor numbers.
This commit is contained in:
parent
3e14072768
commit
120aec25ba
4 changed files with 21 additions and 1 deletions
|
@ -17,4 +17,4 @@
|
|||
* David Korn <dgk@research.att.com> *
|
||||
* *
|
||||
***********************************************************************/
|
||||
#define SH_RELEASE "93u+m 2020-06-28"
|
||||
#define SH_RELEASE "93u+m 2020-06-30"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue