Skip to content

Commit

Permalink
bcachefs: Fix check_snapshot() memcpy
Browse files Browse the repository at this point in the history
check_snapshot() copies the bch_snapshot to a temporary to easily handle
older versions that don't have all the fields of the current version,
but it lacked a min() to correctly handle keys newer and larger than the
current version.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
  • Loading branch information
Kent Overstreet committed Feb 25, 2024
1 parent 097471f commit c4333eb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/bcachefs/snapshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ static int check_snapshot(struct btree_trans *trans,
return 0;

memset(&s, 0, sizeof(s));
memcpy(&s, k.v, bkey_val_bytes(k.k));
memcpy(&s, k.v, min(sizeof(s), bkey_val_bytes(k.k)));

id = le32_to_cpu(s.parent);
if (id) {
Expand Down

0 comments on commit c4333eb

Please sign in to comment.