ref: f44a0a3c6329900774a12b44ffa4f2caa86c018e
parent: 0ac15f45592212176fb388cd51995c6cc53950ed
author: Kaho Ng <ngkaho1234@gmail.com>
date: Thu Jun 30 01:30:28 EDT 2016
ext4: add filetype checking to ext4_mknod
--- a/src/ext4.c
+++ b/src/ext4.c
@@ -2448,9 +2448,23 @@
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);