ext4: silence array overflow warning
authorDan Carpenter <dan.carpenter@oracle.com>
Sat, 5 Aug 2017 23:00:31 +0000 (19:00 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 5 Aug 2017 23:00:31 +0000 (19:00 -0400)
I get a static checker warning:

    fs/ext4/ext4.h:3091 ext4_set_de_type()
    error: buffer overflow 'ext4_type_by_mode' 15 <= 15

It seems unlikely that we would hit this read overflow in real life, but
it's also simple enough to make the array 16 bytes instead of 15.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/ext4.h

index dcbcd9d444d1ee17a64cc83653de45254a0c11d9..2d6d4c9524924b5331bbfd71dee766d9dfb060a4 100644 (file)
@@ -3072,7 +3072,7 @@ extern int ext4_handle_dirty_dirent_node(handle_t *handle,
                                         struct inode *inode,
                                         struct buffer_head *bh);
 #define S_SHIFT 12
-static const unsigned char ext4_type_by_mode[S_IFMT >> S_SHIFT] = {
+static const unsigned char ext4_type_by_mode[(S_IFMT >> S_SHIFT) + 1] = {
        [S_IFREG >> S_SHIFT]    = EXT4_FT_REG_FILE,
        [S_IFDIR >> S_SHIFT]    = EXT4_FT_DIR,
        [S_IFCHR >> S_SHIFT]    = EXT4_FT_CHRDEV,