Skip to content

Commit 7d75161

Browse files
committed
librbd: fix a crash in get_rollback_snap_id
get_rollback_snap_id() did not check if the snapshot it was accessing was a mirror snapshot, causing it to crash if it wasn't. Fixes: https://tracker.ceph.com/issues/70075 Signed-off-by: N Balachandran <[email protected]>
1 parent fe55a0d commit 7d75161

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/librbd/mirror/snapshot/Utils.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ bool get_rollback_snap_id(
3030
uint64_t *rollback_snap_id) {
3131

3232
for (; it != end; it++) {
33-
auto mirror_ns = std::get<cls::rbd::MirrorSnapshotNamespace>(
34-
it->second.snap_namespace);
35-
if (mirror_ns.state != cls::rbd::MIRROR_SNAPSHOT_STATE_NON_PRIMARY) {
33+
auto mirror_ns = std::get_if<cls::rbd::MirrorSnapshotNamespace>(
34+
&it->second.snap_namespace);
35+
if (mirror_ns == nullptr) {
36+
continue;
37+
}
38+
if (mirror_ns->state != cls::rbd::MIRROR_SNAPSHOT_STATE_NON_PRIMARY) {
3639
break;
3740
}
38-
if (mirror_ns.complete) {
41+
if (mirror_ns->complete) {
3942
break;
4043
}
4144
}

0 commit comments

Comments
 (0)