diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2015-06-23 07:28:57 -0400 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2015-06-26 23:09:41 -0400 |
commit | 05732f970020f06b089f24626fd76d527286eea9 (patch) | |
tree | cae74980d6cdb865179a0715d2577f075d567a9a /ext | |
parent | af823f605eae09f4f50c45fed4409131527076b8 (diff) | |
download | perl-05732f970020f06b089f24626fd76d527286eea9.tar.gz |
tcdrain fd can be bad.
Coverity CID 104838.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/POSIX/POSIX.xs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs index 83f6452f9a..ce4c12cdb5 100644 --- a/ext/POSIX/POSIX.xs +++ b/ext/POSIX/POSIX.xs @@ -3499,8 +3499,13 @@ tcdrain(fd) close = 1 dup = 2 CODE: - RETVAL = ix == 1 ? close(fd) - : (ix < 1 ? tcdrain(fd) : dup(fd)); + if (fd >= 0) { + RETVAL = ix == 1 ? close(fd) + : (ix < 1 ? tcdrain(fd) : dup(fd)); + } else { + SETERRNO(EBADF,RMS_IFI); + RETVAL = -1; + } OUTPUT: RETVAL |