From 9a65833c1ea0471e5c39826fe117b9072007515a Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Thu, 3 Mar 2011 06:22:48 +0000 Subject: 2011-03-03 Chris Johns * libcsupport/src/mknod.c, libfs/src/rfs/rtems-rfs-inode.c: PR 1749. Fix the incorrect handling of the file type in the mode value to reject invalid types as per the standard. --- cpukit/libcsupport/src/mknod.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'cpukit/libcsupport') diff --git a/cpukit/libcsupport/src/mknod.c b/cpukit/libcsupport/src/mknod.c index f4673b3275..29aff43c31 100644 --- a/cpukit/libcsupport/src/mknod.c +++ b/cpukit/libcsupport/src/mknod.c @@ -40,9 +40,21 @@ 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 ); + } + rtems_filesystem_get_start_loc( pathname, &i, &temp_loc ); result = (*temp_loc.ops->evalformake_h)( -- cgit v1.2.3