Skip to content

Commit

Permalink
Btrfs: fix array bound checking
Browse files Browse the repository at this point in the history
Otherwise we can execced the array bound of path->slots[].

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
  • Loading branch information
Li Zefan authored and David Sterba committed Oct 20, 2011
1 parent f4c697e commit a05a9bb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions fs/btrfs/ctree.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,9 +902,10 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,

orig_ptr = btrfs_node_blockptr(mid, orig_slot);

if (level < BTRFS_MAX_LEVEL - 1)
if (level < BTRFS_MAX_LEVEL - 1) {
parent = path->nodes[level + 1];
pslot = path->slots[level + 1];
pslot = path->slots[level + 1];
}

/*
* deal with the case where there is only one pointer in the root
Expand Down Expand Up @@ -1107,9 +1108,10 @@ static noinline int push_nodes_for_insert(struct btrfs_trans_handle *trans,
mid = path->nodes[level];
WARN_ON(btrfs_header_generation(mid) != trans->transid);

if (level < BTRFS_MAX_LEVEL - 1)
if (level < BTRFS_MAX_LEVEL - 1) {
parent = path->nodes[level + 1];
pslot = path->slots[level + 1];
pslot = path->slots[level + 1];
}

if (!parent)
return 1;
Expand Down

0 comments on commit a05a9bb

Please sign in to comment.