* hinfo.cc (hinfo::dup2): Guard against out of bounds newfd.
This commit is contained in:
parent
84a1af74a2
commit
5a449743bb
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue