From 19b74f3175705f923fed1c83a13a3a731c5e0de7 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 2 Nov 1999 16:25:05 +0000 Subject: Check for NULL being passed in. --- cpukit/libcsupport/src/readdir.c | 3 +++ cpukit/libcsupport/src/rewinddir.c | 3 +++ cpukit/libcsupport/src/seekdir.c | 6 +++++- cpukit/libcsupport/src/telldir.c | 7 ++++++- 4 files changed, 17 insertions(+), 2 deletions(-) (limited to 'cpukit/libcsupport/src') diff --git a/cpukit/libcsupport/src/readdir.c b/cpukit/libcsupport/src/readdir.c index 570cacd5de..ec41679511 100644 --- a/cpukit/libcsupport/src/readdir.c +++ b/cpukit/libcsupport/src/readdir.c @@ -56,6 +56,9 @@ readdir(dirp) register DIR *dirp; { register struct dirent *dp; + if ( !dirp ) + return NULL; + for (;;) { if (dirp->dd_loc == 0) { dirp->dd_size = getdents (dirp->dd_fd, diff --git a/cpukit/libcsupport/src/rewinddir.c b/cpukit/libcsupport/src/rewinddir.c index cb02fab905..0df578633a 100644 --- a/cpukit/libcsupport/src/rewinddir.c +++ b/cpukit/libcsupport/src/rewinddir.c @@ -24,6 +24,9 @@ void rewinddir( { off_t status; + if ( !dirp ) + return; + status = lseek( dirp->dd_fd, 0, SEEK_SET ); if( status == -1 ) diff --git a/cpukit/libcsupport/src/seekdir.c b/cpukit/libcsupport/src/seekdir.c index 374ca7b5aa..5a2f3bb469 100644 --- a/cpukit/libcsupport/src/seekdir.c +++ b/cpukit/libcsupport/src/seekdir.c @@ -25,12 +25,16 @@ void seekdir( { off_t status; + if ( !dirp ) + return; + status = lseek( dirp->dd_fd, loc, SEEK_SET ); /* * This is not a nice way to error out, but we have no choice here. */ - if( status == -1 ) + + if ( status == -1 ) return; dirp->dd_loc = 0; diff --git a/cpukit/libcsupport/src/telldir.c b/cpukit/libcsupport/src/telldir.c index cea6cc08cb..765bb4ed44 100644 --- a/cpukit/libcsupport/src/telldir.c +++ b/cpukit/libcsupport/src/telldir.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "libio_.h" @@ -26,8 +27,12 @@ long telldir( { rtems_libio_t *iop; + if ( !dirp ) + set_errno_and_return_minus_one( EBADF ); + /* - * Get the file control block structure associated with the file descriptor + * Get the file control block structure associated with the + * file descriptor */ iop = rtems_libio_iop( dirp->dd_fd ); -- cgit v1.2.3