diff options
author | Dimitri John Ledkov <xnox@ubuntu.com> | 2018-07-23 14:32:01 +0100 |
---|---|---|
committer | Dimitri John Ledkov <xnox@ubuntu.com> | 2018-07-23 14:32:01 +0100 |
commit | 3b9cf4c8cda0818e4d3f9892ece9f7d99de13b03 (patch) | |
tree | 59446f505b5bb3b31b1b3bb81af997dda68407c2 /dir-item.c | |
parent | f22f0302575d3a167ee550470c922de82e34342b (diff) |
New upstream release.debian/4.17-1archive/debian/4.17-1
Diffstat (limited to 'dir-item.c')
-rw-r--r-- | dir-item.c | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -263,7 +263,6 @@ int btrfs_delete_one_dir_name(struct btrfs_trans_handle *trans, struct btrfs_path *path, struct btrfs_dir_item *di) { - struct extent_buffer *leaf; u32 sub_item_len; u32 item_len; @@ -273,7 +272,15 @@ int btrfs_delete_one_dir_name(struct btrfs_trans_handle *trans, sub_item_len = sizeof(*di) + btrfs_dir_name_len(leaf, di) + btrfs_dir_data_len(leaf, di); item_len = btrfs_item_size_nr(leaf, path->slots[0]); - if (sub_item_len == item_len) { + + /* + * If @sub_item_len is longer than @item_len, then it means the + * name_len is just corrupted. + * No good idea to know if there is anything we can recover from + * the corrupted item. + * Just delete the item. + */ + if (sub_item_len >= item_len) { ret = btrfs_del_item(trans, root, path); } else { unsigned long ptr = (unsigned long)di; @@ -294,12 +301,6 @@ static int verify_dir_item(struct btrfs_root *root, u16 namelen = BTRFS_NAME_LEN; u8 type = btrfs_dir_type(leaf, dir_item); - if (type >= BTRFS_FT_MAX) { - fprintf(stderr, "invalid dir item type: %d\n", - (int)type); - return 1; - } - if (type == BTRFS_FT_XATTR) namelen = XATTR_NAME_MAX; |