summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2010-02-16 01:47:46 +0000
committerChris Johns <chrisj@rtems.org>2010-02-16 01:47:46 +0000
commitb3b8add4b425709c711ff1515754b09b755aad11 (patch)
tree2c6dc1a1570eeb26066acb2a76b013d5251eebeb /cpukit/libcsupport
parentThis commit was generated by cvs2svn to compensate for changes in r22653, (diff)
downloadrtems-b3b8add4b425709c711ff1515754b09b755aad11.tar.bz2
2010-02-16 Chris Johns <chrisj@rtems.org>
* libcsupport/src/open.c: Tighten the open handler check. 2010-02-16 Sebastian Huber <sebastian.huber@embedded-brains.de> * libcsupport/src/rmdir.c, libcsupport/src/unlink.c: Free the allocated pathloc.
Diffstat (limited to 'cpukit/libcsupport')
-rw-r--r--cpukit/libcsupport/src/open.c2
-rw-r--r--cpukit/libcsupport/src/rmdir.c18
-rw-r--r--cpukit/libcsupport/src/unlink.c18
3 files changed, 27 insertions, 11 deletions
diff --git a/cpukit/libcsupport/src/open.c b/cpukit/libcsupport/src/open.c
index 6b957464f7..25a6f4e239 100644
--- a/cpukit/libcsupport/src/open.c
+++ b/cpukit/libcsupport/src/open.c
@@ -158,7 +158,7 @@ int open(
iop->flags |= rtems_libio_fcntl_flags( flags );
iop->pathinfo = loc;
- if ( !iop->handlers->open_h ) {
+ if ( !iop->handlers || !iop->handlers->open_h ) {
rc = ENOTSUP;
goto done;
}
diff --git a/cpukit/libcsupport/src/rmdir.c b/cpukit/libcsupport/src/rmdir.c
index b66837e115..671cb1a05a 100644
--- a/cpukit/libcsupport/src/rmdir.c
+++ b/cpukit/libcsupport/src/rmdir.c
@@ -34,6 +34,7 @@ int rmdir(
rtems_filesystem_location_info_t loc;
int i;
int result;
+ bool free_parentloc = false;
/*
* Get the parent node of the node we wish to remove. Find the parent path.
@@ -50,6 +51,8 @@ int rmdir(
false );
if ( result != 0 )
return -1;
+
+ free_parentloc = true;
}
/*
@@ -63,7 +66,8 @@ int rmdir(
result = rtems_filesystem_evaluate_relative_path( name , strlen( name ),
0, &loc, false );
if ( result != 0 ) {
- rtems_filesystem_freenode( &parentloc );
+ if ( free_parentloc )
+ rtems_filesystem_freenode( &parentloc );
return -1;
}
@@ -73,13 +77,15 @@ int rmdir(
if ( !loc.ops->node_type_h ){
rtems_filesystem_freenode( &loc );
- rtems_filesystem_freenode( &parentloc );
+ if ( free_parentloc )
+ rtems_filesystem_freenode( &parentloc );
rtems_set_errno_and_return_minus_one( ENOTSUP );
}
if ( (*loc.ops->node_type_h)( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ){
rtems_filesystem_freenode( &loc );
- rtems_filesystem_freenode( &parentloc );
+ if ( free_parentloc )
+ rtems_filesystem_freenode( &parentloc );
rtems_set_errno_and_return_minus_one( ENOTDIR );
}
@@ -89,14 +95,16 @@ int rmdir(
if ( !loc.handlers->rmnod_h ){
rtems_filesystem_freenode( &loc );
- rtems_filesystem_freenode( &parentloc );
+ if ( free_parentloc )
+ rtems_filesystem_freenode( &parentloc );
rtems_set_errno_and_return_minus_one( ENOTSUP );
}
result = (*loc.handlers->rmnod_h)( &parentloc, &loc );
rtems_filesystem_freenode( &loc );
- rtems_filesystem_freenode( &parentloc );
+ if ( free_parentloc )
+ rtems_filesystem_freenode( &parentloc );
return result;
}
diff --git a/cpukit/libcsupport/src/unlink.c b/cpukit/libcsupport/src/unlink.c
index 359e64b4bc..c5c707d3a8 100644
--- a/cpukit/libcsupport/src/unlink.c
+++ b/cpukit/libcsupport/src/unlink.c
@@ -30,6 +30,7 @@ int unlink(
rtems_filesystem_location_info_t loc;
int i;
int result;
+ bool free_parentloc = false;
/*
* Get the node to be unlinked. Find the parent path first.
@@ -46,6 +47,8 @@ int unlink(
false );
if ( result != 0 )
return -1;
+
+ free_parentloc = true;
}
/*
@@ -59,32 +62,37 @@ int unlink(
result = rtems_filesystem_evaluate_relative_path( name , strlen( name ),
0, &loc, false );
if ( result != 0 ) {
- rtems_filesystem_freenode( &parentloc );
+ if ( free_parentloc )
+ rtems_filesystem_freenode( &parentloc );
return -1;
}
if ( !loc.ops->node_type_h ) {
rtems_filesystem_freenode( &loc );
- rtems_filesystem_freenode( &parentloc );
+ if ( free_parentloc )
+ rtems_filesystem_freenode( &parentloc );
rtems_set_errno_and_return_minus_one( ENOTSUP );
}
if ( (*loc.ops->node_type_h)( &loc ) == RTEMS_FILESYSTEM_DIRECTORY ) {
rtems_filesystem_freenode( &loc );
- rtems_filesystem_freenode( &parentloc );
+ if ( free_parentloc )
+ rtems_filesystem_freenode( &parentloc );
rtems_set_errno_and_return_minus_one( EISDIR );
}
if ( !loc.ops->unlink_h ) {
rtems_filesystem_freenode( &loc );
- rtems_filesystem_freenode( &parentloc );
+ if ( free_parentloc )
+ rtems_filesystem_freenode( &parentloc );
rtems_set_errno_and_return_minus_one( ENOTSUP );
}
result = (*loc.ops->unlink_h)( &parentloc, &loc );
rtems_filesystem_freenode( &loc );
- rtems_filesystem_freenode( &parentloc );
+ if ( free_parentloc )
+ rtems_filesystem_freenode( &parentloc );
return result;
}