diff options
author | Christopher Faylor <me@cgf.cx> | 2000-06-26 19:27:12 +0400 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2000-06-26 19:27:12 +0400 |
commit | 5a449743bbcfaccd5e60ffd3e6f62d345802a628 (patch) | |
tree | d42f15763e048272ed697274de314baf0c90f84b | |
parent | 84a1af74a218779daac9b1e2e2634701ecd5f388 (diff) |
* hinfo.cc (hinfo::dup2): Guard against out of bounds newfd.
-rw-r--r-- | winsup/cygwin/ChangeLog | 4 | ||||
-rw-r--r-- | winsup/cygwin/dtable.cc | 8 |
2 files changed, 11 insertions, 1 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index c96a667e4..59a963fea 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +Mon Jun 26 11:25:29 2000 Christopher Faylor <cgf@cygnus.com> + + * hinfo.cc (hinfo::dup2): Guard against out of bounds newfd. + Sat Jun 24 23:43:06 2000 Christopher Faylor <cgf@cygnus.com> * grp.cc (read_etc_group): Open file in text mode. diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index 40d31a920..9f9d0b65b 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -324,7 +324,7 @@ hinfo::dup2 (int oldfd, int newfd) if (not_open (oldfd)) { - syscall_printf("dup2: fd %d not open", oldfd); + syscall_printf ("fd %d not open", oldfd); set_errno (EBADF); goto done; } @@ -342,6 +342,12 @@ hinfo::dup2 (int oldfd, int newfd) } SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK,"dup"); + if (newfd >= dtable.size || newfd < 0) + { + syscall_printf ("new fd out of bounds: %d", newfd); + set_errno (EBADF); + goto done; + } if (!not_open (newfd)) _close (newfd); fds[newfd] = newfh; |