From 85f1b9aa1130d8b4d72885b851594af0b01c6cc1 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Sun, 24 Jul 2011 20:26:14 +0000 Subject: 2011-07-24 Joel Sherrill PR 1839/filesystem * libcsupport/include/rtems/libio_.h, libcsupport/src/fchdir.c, libcsupport/src/fdatasync.c, libcsupport/src/fpathconf.c, libcsupport/src/fsync.c, libcsupport/src/read.c, libcsupport/src/readv.c, libcsupport/src/write.c, libcsupport/src/writev.c: Some calls did not return proper status for permission errors or incorrectly permissions at all. --- cpukit/ChangeLog | 10 ++++++++++ cpukit/libcsupport/include/rtems/libio_.h | 25 ++++++++++++++++++------- cpukit/libcsupport/src/fchdir.c | 8 +------- cpukit/libcsupport/src/fdatasync.c | 4 ++-- cpukit/libcsupport/src/fpathconf.c | 3 +-- cpukit/libcsupport/src/fsync.c | 3 +-- cpukit/libcsupport/src/read.c | 4 ++-- cpukit/libcsupport/src/readv.c | 4 ++-- cpukit/libcsupport/src/write.c | 4 ++-- cpukit/libcsupport/src/writev.c | 4 ++-- 10 files changed, 41 insertions(+), 28 deletions(-) diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index 59fa84c304..4196c42dda 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,13 @@ +2011-07-24 Joel Sherrill + + PR 1839/filesystem + * libcsupport/include/rtems/libio_.h, libcsupport/src/fchdir.c, + libcsupport/src/fdatasync.c, libcsupport/src/fpathconf.c, + libcsupport/src/fsync.c, libcsupport/src/read.c, + libcsupport/src/readv.c, libcsupport/src/write.c, + libcsupport/src/writev.c: Some calls did not return proper status for + permission errors or incorrectly permissions at all. + 2011-07-19 Joel Sherrill PR 1838/filesystem diff --git a/cpukit/libcsupport/include/rtems/libio_.h b/cpukit/libcsupport/include/rtems/libio_.h index f64fefb2e8..2b6bbf687d 100644 --- a/cpukit/libcsupport/include/rtems/libio_.h +++ b/cpukit/libcsupport/include/rtems/libio_.h @@ -124,19 +124,30 @@ extern rtems_libio_t *rtems_libio_iop_freelist; } while (0) /* - * rtems_libio_check_permissions + * rtems_libio_check_permissions_with_error * * Macro to check if a file descriptor is open for this operation. + * On failure, return the user specified error. */ -#define rtems_libio_check_permissions(_iop, _flag) \ - do { \ - if (((_iop)->flags & (_flag)) == 0) { \ - rtems_set_errno_and_return_minus_one( EINVAL ); \ - return -1; \ - } \ +#define rtems_libio_check_permissions_with_error(_iop, _flag, _errno) \ + do { \ + if (((_iop)->flags & (_flag)) == 0) { \ + rtems_set_errno_and_return_minus_one( _errno ); \ + return -1; \ + } \ } while (0) +/* + * rtems_libio_check_permissions + * + * Macro to check if a file descriptor is open for this operation. + * On failure, return EINVAL + */ + +#define rtems_libio_check_permissions(_iop, _flag) \ + rtems_libio_check_permissions_with_error(_iop, _flag, EINVAL ) + /* * rtems_filesystem_freenode * diff --git a/cpukit/libcsupport/src/fchdir.c b/cpukit/libcsupport/src/fchdir.c index 603288614d..3069788f95 100644 --- a/cpukit/libcsupport/src/fchdir.c +++ b/cpukit/libcsupport/src/fchdir.c @@ -1,7 +1,7 @@ /* * fchdir() - compatible with SVr4, 4.4BSD and X/OPEN - Change Directory * - * COPYRIGHT (c) 1989-2000. + * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -35,12 +35,6 @@ int fchdir( iop = rtems_libio_iop( fd ); rtems_libio_check_is_open(iop); - /* - * Now process the fchmod(). - */ - - rtems_libio_check_permissions( iop, LIBIO_FLAGS_READ ); - /* * Verify you can change directory into this node. */ diff --git a/cpukit/libcsupport/src/fdatasync.c b/cpukit/libcsupport/src/fdatasync.c index c2b4db43ae..5a7ba4244a 100644 --- a/cpukit/libcsupport/src/fdatasync.c +++ b/cpukit/libcsupport/src/fdatasync.c @@ -1,7 +1,7 @@ /* * fdatasync() - POSIX 1003.1b 6.6.2 - Synchronize the Data of a File * - * COPYRIGHT (c) 1989-1999. + * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -29,7 +29,7 @@ int fdatasync( rtems_libio_check_fd( fd ); iop = rtems_libio_iop( fd ); rtems_libio_check_is_open(iop); - rtems_libio_check_permissions( iop, LIBIO_FLAGS_WRITE ); + rtems_libio_check_permissions_with_error( iop, LIBIO_FLAGS_WRITE, EBADF ); /* * Now process the fdatasync(). diff --git a/cpukit/libcsupport/src/fpathconf.c b/cpukit/libcsupport/src/fpathconf.c index accaae1585..71edaf6ce9 100644 --- a/cpukit/libcsupport/src/fpathconf.c +++ b/cpukit/libcsupport/src/fpathconf.c @@ -1,7 +1,7 @@ /* * fpathconf() - POSIX 1003.1b - 5.7.1 - Configurable Pathname Varables * - * COPYRIGHT (c) 1989-1999. + * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -33,7 +33,6 @@ long fpathconf( rtems_libio_check_fd(fd); iop = rtems_libio_iop(fd); rtems_libio_check_is_open(iop); - rtems_libio_check_permissions(iop, LIBIO_FLAGS_READ); /* * Now process the information request. diff --git a/cpukit/libcsupport/src/fsync.c b/cpukit/libcsupport/src/fsync.c index cfd8e8d49b..c7a7745859 100644 --- a/cpukit/libcsupport/src/fsync.c +++ b/cpukit/libcsupport/src/fsync.c @@ -1,7 +1,7 @@ /* * fsync() - POSIX 1003.1b 6.6.1 - Synchronize the State of a File * - * COPYRIGHT (c) 1989-1999. + * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -29,7 +29,6 @@ int fsync( rtems_libio_check_fd( fd ); iop = rtems_libio_iop( fd ); rtems_libio_check_is_open(iop); - rtems_libio_check_permissions( iop, LIBIO_FLAGS_WRITE ); /* * Now process the fsync(). diff --git a/cpukit/libcsupport/src/read.c b/cpukit/libcsupport/src/read.c index 286edf3bab..77aa4e5206 100644 --- a/cpukit/libcsupport/src/read.c +++ b/cpukit/libcsupport/src/read.c @@ -1,7 +1,7 @@ /* * read() - POSIX 1003.1b 6.4.1 - Read From a File * - * COPYRIGHT (c) 1989-1999. + * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -32,7 +32,7 @@ ssize_t read( rtems_libio_check_is_open( iop ); rtems_libio_check_buffer( buffer ); rtems_libio_check_count( count ); - rtems_libio_check_permissions( iop, LIBIO_FLAGS_READ ); + rtems_libio_check_permissions_with_error( iop, LIBIO_FLAGS_READ, EBADF ); /* * Now process the read(). diff --git a/cpukit/libcsupport/src/readv.c b/cpukit/libcsupport/src/readv.c index 7b77c11fe2..c6997a7fe4 100644 --- a/cpukit/libcsupport/src/readv.c +++ b/cpukit/libcsupport/src/readv.c @@ -5,7 +5,7 @@ * * http://www.opengroup.org/onlinepubs/009695399/functions/readv.html * - * COPYRIGHT (c) 1989-2007. + * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -40,7 +40,7 @@ ssize_t readv( rtems_libio_check_fd( fd ); iop = rtems_libio_iop( fd ); rtems_libio_check_is_open( iop ); - rtems_libio_check_permissions( iop, LIBIO_FLAGS_READ ); + rtems_libio_check_permissions_with_error( iop, LIBIO_FLAGS_READ, EBADF ); /* * Argument validation on IO vector diff --git a/cpukit/libcsupport/src/write.c b/cpukit/libcsupport/src/write.c index 3bda204015..0850bb69b2 100644 --- a/cpukit/libcsupport/src/write.c +++ b/cpukit/libcsupport/src/write.c @@ -1,7 +1,7 @@ /* * write() - POSIX 1003.1b 6.4.2 - Write to a File * - * COPYRIGHT (c) 1989-2007. + * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -39,7 +39,7 @@ ssize_t write( rtems_libio_check_is_open( iop ); rtems_libio_check_buffer( buffer ); rtems_libio_check_count( count ); - rtems_libio_check_permissions( iop, LIBIO_FLAGS_WRITE ); + rtems_libio_check_permissions_with_error( iop, LIBIO_FLAGS_WRITE, EBADF ); /* * Now process the write() request. diff --git a/cpukit/libcsupport/src/writev.c b/cpukit/libcsupport/src/writev.c index 88d495da56..97f7322065 100644 --- a/cpukit/libcsupport/src/writev.c +++ b/cpukit/libcsupport/src/writev.c @@ -5,7 +5,7 @@ * * http://www.opengroup.org/onlinepubs/009695399/functions/writev.html * - * COPYRIGHT (c) 1989-2007. + * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -41,7 +41,7 @@ ssize_t writev( rtems_libio_check_fd( fd ); iop = rtems_libio_iop( fd ); rtems_libio_check_is_open( iop ); - rtems_libio_check_permissions( iop, LIBIO_FLAGS_WRITE ); + rtems_libio_check_permissions_with_error( iop, LIBIO_FLAGS_WRITE, EBADF ); /* * Argument validation on IO vector -- cgit v1.2.3