Browse Source

ext4: add filetype checking to ext4_mknod

pull/12/head
Kaho Ng 8 years ago
parent
commit
f44a0a3c63
  1. 16
      src/ext4.c

16
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);

Loading…
Cancel
Save