Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2009-08-22 01:19:45 +0400
committerChristopher Faylor <me@cgf.cx>2009-08-22 01:19:45 +0400
commite41f43a1a675ee6d0f21f2ab611c97ffe9c22088 (patch)
tree35bca25fa9908904bf55b91e93381b2d34a20e82
parent24149e4aa93d8d5739b610624c0c1db36f487ab5 (diff)
* fcntl.cc (fcntl64): Detect negative fd as error.
-rw-r--r--winsup/cygwin/ChangeLog4
-rw-r--r--winsup/cygwin/fcntl.cc8
2 files changed, 11 insertions, 1 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 9c08c56da..316a48a3e 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,7 @@
+2009-08-21 Christopher Faylor <me+cygwin@cgf.cx>
+
+ * fcntl.cc (fcntl64): Detect negative fd as error.
+
2009-08-21 Corinna Vinschen <corinna@vinschen.de>
* mmap.cc (mmap64): Allocate fh_disk_file on cygheap. Delete
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: