diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-03-03 13:38:52 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-03-03 13:38:52 +0000 |
commit | 5357e24abca0d493d8ff7b1f691bb661db814116 (patch) | |
tree | 1273c3039a78eb0a9dea4f842fd7ce050a008ee9 | |
parent | Ada getting started is gone. (diff) | |
download | rtems-5357e24abca0d493d8ff7b1f691bb661db814116.tar.bz2 |
2011-03-03 Chris Johns <chrisj@rtems.org>
PR 1749/filesystem
* libcsupport/src/mknod.c: Fix the incorrect handling of the file type
in the mode value o reject invalid types as per the standard.
-rw-r--r-- | cpukit/ChangeLog | 6 | ||||
-rw-r--r-- | cpukit/libcsupport/src/mknod.c | 15 |
2 files changed, 19 insertions, 2 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index 0d44529c98..6e2e393ce3 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,9 @@ +2011-03-03 Chris Johns <chrisj@rtems.org> + + PR 1749/filesystem + * libcsupport/src/mknod.c: Fix the incorrect handling of the file type + in the mode value o reject invalid types as per the standard. + 2011-01-21 Eric Norum <wenorum@lbl.gov> * libmisc/capture/capture.c: Avoid using TCB of task just deleted. diff --git a/cpukit/libcsupport/src/mknod.c b/cpukit/libcsupport/src/mknod.c index c786c6d756..c2c86e7afe 100644 --- a/cpukit/libcsupport/src/mknod.c +++ b/cpukit/libcsupport/src/mknod.c @@ -40,8 +40,19 @@ int mknod( const char *name_start; int result; - if ( !(mode & (S_IFREG|S_IFCHR|S_IFBLK|S_IFIFO) ) ) - rtems_set_errno_and_return_minus_one( EINVAL ); + /* + * The file type is field within the mode. Check we have a sane mode set. + */ + switch (mode & S_IFMT) { + case S_IFDIR: + case S_IFCHR: + case S_IFBLK: + case S_IFREG: + case S_IFIFO: + break; + default: + rtems_set_errno_and_return_minus_one( EINVAL ); + } if ( S_ISFIFO(mode) ) rtems_set_errno_and_return_minus_one( ENOTSUP ); |