Skip to content

Commit 79d16d4

Browse files
add invalid commit floor corruption detection
1 parent 56eab1b commit 79d16d4

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

storage/src/qmdb/immutable/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ where
208208
let inactivity_floor_loc = last_op
209209
.has_floor()
210210
.expect("last operation should be a commit with floor");
211+
if inactivity_floor_loc > last_commit_loc {
212+
return Err(Error::DataCorrupted("inactivity floor exceeds last commit"));
213+
}
211214

212215
// Replay the log from the inactivity floor to build the snapshot.
213216
build_snapshot_from_log::<F, _, _, _>(

storage/src/qmdb/store/db.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,11 @@ where
370370
let reader = log.reader().await;
371371
let op = reader.read(*last_commit_loc).await?;
372372
let inactivity_floor_loc = op.has_floor().expect("last op should be a commit");
373+
if inactivity_floor_loc > last_commit_loc {
374+
return Err(crate::qmdb::Error::DataCorrupted(
375+
"inactivity floor exceeds last commit",
376+
));
377+
}
373378
let active_keys =
374379
build_snapshot_from_log(inactivity_floor_loc, &reader, &mut snapshot, |_, _| {})
375380
.await?;

0 commit comments

Comments
 (0)