summaryrefslogtreecommitdiffstats
path: root/c/src/exec/include/rtems/libio_.h
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1999-01-20 15:48:22 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1999-01-20 15:48:22 +0000
commit2d733c424ba21cfa55386e81d668036cc801fc6d (patch)
tree2b578a8d689c495f9c28c0a63d5c3ed41b1d6e0d /c/src/exec/include/rtems/libio_.h
parentRemoved referencing to network driver since it has not been merged yet. (diff)
downloadrtems-2d733c424ba21cfa55386e81d668036cc801fc6d.tar.bz2
More general fix based on bug report and patch from Ian Lance Taylor
<ian@airs.com> to fix this problem: There is a small bug in __rtems_close in c/src/lib/libc/libio.c. It does not check whether the file descriptor it is passed is open. This can cause it to make a null dereference if it is passed a file descriptor which is in the valid range but which was not opened, or which was already closed.
Diffstat (limited to 'c/src/exec/include/rtems/libio_.h')
-rw-r--r--c/src/exec/include/rtems/libio_.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/c/src/exec/include/rtems/libio_.h b/c/src/exec/include/rtems/libio_.h
index d595500430..995809b6d5 100644
--- a/c/src/exec/include/rtems/libio_.h
+++ b/c/src/exec/include/rtems/libio_.h
@@ -103,6 +103,20 @@ extern mode_t rtems_filesystem_umask;
((((unsigned32)(_fd)) < rtems_libio_number_iops) ? \
&rtems_libio_iops[_fd] : 0)
+/*
+ * rtems_libio_check_is_open
+ *
+ * Macro to check if a file descriptor is actually open.
+ */
+
+#define rtems_libio_check_is_open(_iop) \
+ do { \
+ if (((_iop)->flags & LIBIO_FLAGS_OPEN) == 0) { \
+ errno = EBADF; \
+ return -1; \
+ } \
+ } while (0)
+
/*
* rtems_libio_check_fd
*
@@ -118,7 +132,7 @@ extern mode_t rtems_filesystem_umask;
} while (0)
/*
- * rtems_libio_check_fd
+ * rtems_libio_check_buffer
*
* Macro to check if a buffer pointer is valid.
*/