f2fs-tools: set namelen parameter of convert_encrypted_name as unsigned
authorSheng Yong <shengyong1@huawei.com>
Tue, 10 Jul 2018 14:47:38 +0000 (22:47 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 28 Aug 2018 06:49:26 +0000 (23:49 -0700)
To avoid overflow, set namelen parameter of convert_encrypted_name as
unsigned int. convert_encrypted_name() will check if namelen exceeds the
limitation.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fsck/fsck.c
fsck/fsck.h
fsck/mount.c

index 544e008..21d93a4 100644 (file)
@@ -660,7 +660,7 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
        u64 i_blocks = le64_to_cpu(node_blk->i.i_blocks);
        int ofs;
        unsigned char *en;
-       int namelen;
+       u32 namelen;
        unsigned int idx = 0;
        int need_fix = 0;
        int ret;
@@ -1145,7 +1145,7 @@ static int digest_encode(const char *src, int len, char *dst)
        return cp - dst;
 }
 
-int convert_encrypted_name(unsigned char *name, int len,
+int convert_encrypted_name(unsigned char *name, u32 len,
                                unsigned char *new, int enc_name)
 {
        if (!enc_name) {
@@ -1166,7 +1166,7 @@ static void print_dentry(__u32 depth, __u8 *name,
 {
        int last_de = 0;
        int next_idx = 0;
-       int name_len;
+       u32 name_len;
        unsigned int i;
        int bit_offset;
        unsigned char new[F2FS_NAME_LEN + 1];
index e3e6723..bbcf589 100644 (file)
@@ -146,7 +146,7 @@ int fsck_chk_inline_dentries(struct f2fs_sb_info *, struct f2fs_node *,
                struct child_info *);
 int fsck_chk_meta(struct f2fs_sb_info *sbi);
 int fsck_chk_curseg_info(struct f2fs_sb_info *);
-int convert_encrypted_name(unsigned char *, int, unsigned char *, int);
+int convert_encrypted_name(unsigned char *, u32, unsigned char *, int);
 
 extern void update_free_segments(struct f2fs_sb_info *);
 void print_cp_state(u32);
index 0042306..2fc21f1 100644 (file)
@@ -175,7 +175,7 @@ void print_inode_info(struct f2fs_sb_info *sbi,
        struct f2fs_xattr_entry *ent;
        unsigned char en[F2FS_NAME_LEN + 1];
        unsigned int i = 0;
-       int namelen = le32_to_cpu(inode->i_namelen);
+       u32 namelen = le32_to_cpu(inode->i_namelen);
        int enc_name = file_enc_name(inode);
        int ofs = __get_extra_isize(inode);