dup2: fix off-by-one crash
* dtable.cc (dup3): Fix off-by-one. (find_unused_handle): Reduce time spent expanding during dup. * syscalls.cc (setdtablesize): Report error on invalid value.
This commit is contained in:
@@ -2578,6 +2578,12 @@ system (const char *cmdstring)
|
||||
extern "C" int
|
||||
setdtablesize (int size)
|
||||
{
|
||||
if (size < 0)
|
||||
{
|
||||
set_errno (EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (size <= (int)cygheap->fdtab.size || cygheap->fdtab.extend (size - cygheap->fdtab.size))
|
||||
return 0;
|
||||
|
||||
|
Reference in New Issue
Block a user