forked from Imagelibrary/rtems
Check for NULL being passed in.
This commit is contained in:
@@ -56,6 +56,9 @@ readdir(dirp)
|
|||||||
register DIR *dirp; {
|
register DIR *dirp; {
|
||||||
register struct dirent *dp;
|
register struct dirent *dp;
|
||||||
|
|
||||||
|
if ( !dirp )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (dirp->dd_loc == 0) {
|
if (dirp->dd_loc == 0) {
|
||||||
dirp->dd_size = getdents (dirp->dd_fd,
|
dirp->dd_size = getdents (dirp->dd_fd,
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ void rewinddir(
|
|||||||
{
|
{
|
||||||
off_t status;
|
off_t status;
|
||||||
|
|
||||||
|
if ( !dirp )
|
||||||
|
return;
|
||||||
|
|
||||||
status = lseek( dirp->dd_fd, 0, SEEK_SET );
|
status = lseek( dirp->dd_fd, 0, SEEK_SET );
|
||||||
|
|
||||||
if( status == -1 )
|
if( status == -1 )
|
||||||
|
|||||||
@@ -25,12 +25,16 @@ void seekdir(
|
|||||||
{
|
{
|
||||||
off_t status;
|
off_t status;
|
||||||
|
|
||||||
|
if ( !dirp )
|
||||||
|
return;
|
||||||
|
|
||||||
status = lseek( dirp->dd_fd, loc, SEEK_SET );
|
status = lseek( dirp->dd_fd, loc, SEEK_SET );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is not a nice way to error out, but we have no choice here.
|
* This is not a nice way to error out, but we have no choice here.
|
||||||
*/
|
*/
|
||||||
if( status == -1 )
|
|
||||||
|
if ( status == -1 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dirp->dd_loc = 0;
|
dirp->dd_loc = 0;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include "libio_.h"
|
#include "libio_.h"
|
||||||
|
|
||||||
@@ -26,8 +27,12 @@ long telldir(
|
|||||||
{
|
{
|
||||||
rtems_libio_t *iop;
|
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 );
|
iop = rtems_libio_iop( dirp->dd_fd );
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ readdir(dirp)
|
|||||||
register DIR *dirp; {
|
register DIR *dirp; {
|
||||||
register struct dirent *dp;
|
register struct dirent *dp;
|
||||||
|
|
||||||
|
if ( !dirp )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (dirp->dd_loc == 0) {
|
if (dirp->dd_loc == 0) {
|
||||||
dirp->dd_size = getdents (dirp->dd_fd,
|
dirp->dd_size = getdents (dirp->dd_fd,
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ void rewinddir(
|
|||||||
{
|
{
|
||||||
off_t status;
|
off_t status;
|
||||||
|
|
||||||
|
if ( !dirp )
|
||||||
|
return;
|
||||||
|
|
||||||
status = lseek( dirp->dd_fd, 0, SEEK_SET );
|
status = lseek( dirp->dd_fd, 0, SEEK_SET );
|
||||||
|
|
||||||
if( status == -1 )
|
if( status == -1 )
|
||||||
|
|||||||
@@ -25,12 +25,16 @@ void seekdir(
|
|||||||
{
|
{
|
||||||
off_t status;
|
off_t status;
|
||||||
|
|
||||||
|
if ( !dirp )
|
||||||
|
return;
|
||||||
|
|
||||||
status = lseek( dirp->dd_fd, loc, SEEK_SET );
|
status = lseek( dirp->dd_fd, loc, SEEK_SET );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is not a nice way to error out, but we have no choice here.
|
* This is not a nice way to error out, but we have no choice here.
|
||||||
*/
|
*/
|
||||||
if( status == -1 )
|
|
||||||
|
if ( status == -1 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dirp->dd_loc = 0;
|
dirp->dd_loc = 0;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include "libio_.h"
|
#include "libio_.h"
|
||||||
|
|
||||||
@@ -26,8 +27,12 @@ long telldir(
|
|||||||
{
|
{
|
||||||
rtems_libio_t *iop;
|
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 );
|
iop = rtems_libio_iop( dirp->dd_fd );
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ readdir(dirp)
|
|||||||
register DIR *dirp; {
|
register DIR *dirp; {
|
||||||
register struct dirent *dp;
|
register struct dirent *dp;
|
||||||
|
|
||||||
|
if ( !dirp )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (dirp->dd_loc == 0) {
|
if (dirp->dd_loc == 0) {
|
||||||
dirp->dd_size = getdents (dirp->dd_fd,
|
dirp->dd_size = getdents (dirp->dd_fd,
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ void rewinddir(
|
|||||||
{
|
{
|
||||||
off_t status;
|
off_t status;
|
||||||
|
|
||||||
|
if ( !dirp )
|
||||||
|
return;
|
||||||
|
|
||||||
status = lseek( dirp->dd_fd, 0, SEEK_SET );
|
status = lseek( dirp->dd_fd, 0, SEEK_SET );
|
||||||
|
|
||||||
if( status == -1 )
|
if( status == -1 )
|
||||||
|
|||||||
@@ -25,12 +25,16 @@ void seekdir(
|
|||||||
{
|
{
|
||||||
off_t status;
|
off_t status;
|
||||||
|
|
||||||
|
if ( !dirp )
|
||||||
|
return;
|
||||||
|
|
||||||
status = lseek( dirp->dd_fd, loc, SEEK_SET );
|
status = lseek( dirp->dd_fd, loc, SEEK_SET );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is not a nice way to error out, but we have no choice here.
|
* This is not a nice way to error out, but we have no choice here.
|
||||||
*/
|
*/
|
||||||
if( status == -1 )
|
|
||||||
|
if ( status == -1 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dirp->dd_loc = 0;
|
dirp->dd_loc = 0;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include "libio_.h"
|
#include "libio_.h"
|
||||||
|
|
||||||
@@ -26,8 +27,12 @@ long telldir(
|
|||||||
{
|
{
|
||||||
rtems_libio_t *iop;
|
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 );
|
iop = rtems_libio_iop( dirp->dd_fd );
|
||||||
|
|||||||
Reference in New Issue
Block a user