f2fs-tools: set namelen parameter of convert_encrypted_name as unsigned
PATCH 1/1 f2fs-tools: set namelen parameter of convert_encrypted_name as unsigned
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 <[email protected]>
--- fsck/fsck.c | 6 +++--- fsck/fsck.h | 2 +- fsck/mount.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
fsck/fsck.c +3 -3
@@ -657,7 +657,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;
@@ -1139,7 +1139,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) {
@@ -1160,7 +1160,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 ];
fsck/fsck.h +1 -1
@@ -145,7 +145,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 );
fsck/mount.c +1 -1
@@ -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);
Signature · 6 lines
2.17.1 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Quoted 5 lines · Sheng Yong
To avoid overflow, set namelen parameter of
convert_encrypted_nameas unsigned int.convert_encrypted_name()will check if namelen exceeds the limitation.Signed-off-by Sheng Yong <[email protected]>
Reviewed-by Chao Yu <[email protected]>
Thanks,
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot