mirror of
https://gitee.com/openharmony/third_party_f2fs-tools
synced 2024-11-23 10:10:00 +00:00
fsck.f2fs: fix potential overflow of copying i_name
If i_namelen is corrupted, there may be an overflow when doing memcpy. Signed-off-by: Sheng Yong <shengyong@oppo.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
e9217c4777
commit
792c0b4a71
@ -742,8 +742,10 @@ check_next:
|
|||||||
|
|
||||||
if (ftype == F2FS_FT_DIR) {
|
if (ftype == F2FS_FT_DIR) {
|
||||||
f2fs_set_main_bitmap(sbi, ni->blk_addr, CURSEG_HOT_NODE);
|
f2fs_set_main_bitmap(sbi, ni->blk_addr, CURSEG_HOT_NODE);
|
||||||
memcpy(child.p_name, node_blk->i.i_name,
|
namelen = le32_to_cpu(node_blk->i.i_namelen);
|
||||||
node_blk->i.i_namelen);
|
if (namelen > F2FS_NAME_LEN)
|
||||||
|
namelen = F2FS_NAME_LEN;
|
||||||
|
memcpy(child.p_name, node_blk->i.i_name, namelen);
|
||||||
} else {
|
} else {
|
||||||
if (f2fs_test_main_bitmap(sbi, ni->blk_addr) == 0) {
|
if (f2fs_test_main_bitmap(sbi, ni->blk_addr) == 0) {
|
||||||
f2fs_set_main_bitmap(sbi, ni->blk_addr,
|
f2fs_set_main_bitmap(sbi, ni->blk_addr,
|
||||||
|
Loading…
Reference in New Issue
Block a user