summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKaho Ng <ngkaho1234@gmail.com>2016-06-30 05:30:28 +0800
committerKaho Ng <ngkaho1234@gmail.com>2016-06-30 05:40:08 +0800
commitf44a0a3c6329900774a12b44ffa4f2caa86c018e (patch)
treea70171d08d393a9365edac872dc6a4035092e942 /src
parent0ac15f45592212176fb388cd51995c6cc53950ed (diff)
ext4: add filetype checking to ext4_mknod
Diffstat (limited to 'src')
-rw-r--r--src/ext4.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/ext4.c b/src/ext4.c
index 0f2f07a..7f10e11 100644
--- a/src/ext4.c
+++ b/src/ext4.c
@@ -2448,9 +2448,23 @@ int ext4_mknod(const char *path, int filetype, uint32_t dev)
if (mp->fs.read_only)
return EROFS;
+ /*
+ * The filetype shouldn't be normal file, directory or
+ * unknown.
+ */
if (filetype == EXT4_DE_UNKNOWN ||
filetype == EXT4_DE_REG_FILE ||
- filetype == EXT4_DE_DIR)
+ filetype == EXT4_DE_DIR ||
+ filetype == EXT4_DE_SYMLINK)
+ return EINVAL;
+
+ /*
+ * Nor should it be any bogus value.
+ */
+ if (filetype != EXT4_DE_CHRDEV &&
+ filetype != EXT4_DE_BLKDEV &&
+ filetype != EXT4_DE_FIFO &&
+ filetype != EXT4_DE_SOCK)
return EINVAL;
EXT4_MP_LOCK(mp);