summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2011-03-03 06:33:16 +0000
committerChris Johns <chrisj@rtems.org>2011-03-03 06:33:16 +0000
commitb3c3864678906c02e8c2eaaa86ac4dace2aeefc8 (patch)
treecb86590c9f2e9a801c234d39e71b52569e55bfd0 /cpukit
parentRegenerate. (diff)
downloadrtems-b3c3864678906c02e8c2eaaa86ac4dace2aeefc8.tar.bz2
2011-03-03 Chris Johns <chrisj@rtems.org>
* 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.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/ChangeLog6
-rw-r--r--cpukit/libcsupport/src/mknod.c18
-rw-r--r--cpukit/libfs/src/rfs/rtems-rfs-inode.c15
3 files changed, 36 insertions, 3 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog
index 467a94b441..211f0c647f 100644
--- a/cpukit/ChangeLog
+++ b/cpukit/ChangeLog
@@ -1,3 +1,9 @@
+2011-03-03 Chris Johns <chrisj@rtems.org>
+
+ * 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.
+
2011-02-08 Brett Swimley <bswimley@advanced.pro>
* libfs/src/rfs/rtems-rfs-rtems.c: Fix bug where the eval path did
diff --git a/cpukit/libcsupport/src/mknod.c b/cpukit/libcsupport/src/mknod.c
index 2d1db0fc3d..4e237aaa32 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 );
if ( !temp_loc.ops->evalformake_h ) {
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-inode.c b/cpukit/libfs/src/rfs/rtems-rfs-inode.c
index 608048e84b..ab3f4b7e65 100644
--- a/cpukit/libfs/src/rfs/rtems-rfs-inode.c
+++ b/cpukit/libfs/src/rfs/rtems-rfs-inode.c
@@ -211,6 +211,21 @@ rtems_rfs_inode_create (rtems_rfs_file_system* fs,
printf (" type:%s mode:%04x (%03o)\n", type, mode, mode & ((1 << 10) - 1));
}
+ /*
+ * The file type is field within the mode. Check we have a sane mode set.
+ */
+ switch (mode & RTEMS_RFS_S_IFMT)
+ {
+ case RTEMS_RFS_S_IFDIR:
+ case RTEMS_RFS_S_IFCHR:
+ case RTEMS_RFS_S_IFBLK:
+ case RTEMS_RFS_S_IFREG:
+ case RTEMS_RFS_S_IFLNK:
+ break;
+ default:
+ return EINVAL;
+ }
+
rc = rtems_rfs_inode_alloc (fs, parent, ino);
if (rc > 0)
return rc;