diff options
Diffstat (limited to 'winsup/cygwin/fcntl.cc')
-rw-r--r-- | winsup/cygwin/fcntl.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/winsup/cygwin/fcntl.cc b/winsup/cygwin/fcntl.cc index 442686268..bb41f05c5 100644 --- a/winsup/cygwin/fcntl.cc +++ b/winsup/cygwin/fcntl.cc @@ -40,7 +40,13 @@ fcntl64 (int fd, int cmd, ...) switch (cmd) { case F_DUPFD: - res = dup2 (fd, cygheap_fdnew (((int) arg) - 1)); + if ((int) arg >= 0) + res = dup2 (fd, cygheap_fdnew (((int) arg) - 1)); + else + { + set_errno (EINVAL); + res = -1; + } break; case F_GETLK: case F_SETLK: |