Skip to content

Commit c4333eb

Browse files
author
Kent Overstreet
committed
bcachefs: Fix check_snapshot() memcpy
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 <[email protected]>
1 parent 097471f commit c4333eb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/bcachefs/snapshot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ static int check_snapshot(struct btree_trans *trans,
728728
return 0;
729729

730730
memset(&s, 0, sizeof(s));
731-
memcpy(&s, k.v, bkey_val_bytes(k.k));
731+
memcpy(&s, k.v, min(sizeof(s), bkey_val_bytes(k.k)));
732732

733733
id = le32_to_cpu(s.parent);
734734
if (id) {

0 commit comments

Comments
 (0)