about summary refs log tree commit diff
path: root/sysdeps/pthread/aio_cancel.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/pthread/aio_cancel.c')
-rw-r--r--sysdeps/pthread/aio_cancel.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sysdeps/pthread/aio_cancel.c b/sysdeps/pthread/aio_cancel.c
index c2fe6da9ee..d62586b903 100644
--- a/sysdeps/pthread/aio_cancel.c
+++ b/sysdeps/pthread/aio_cancel.c
@@ -1,5 +1,5 @@
 /* Cancel requests associated with given file descriptor.
-   Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 2000, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -43,6 +43,13 @@ aio_cancel (fildes, aiocbp)
   struct requestlist *req = NULL;
   int result = AIO_ALLDONE;
 
+  /* If fildes is invalid, error. */
+  if (fcntl (fildes, F_GETFL) < 0)
+    {
+      __set_errno (EBADF);
+      return -1;
+    }
+
   /* Request the mutex.  */
   pthread_mutex_lock (&__aio_requests_mutex);