From 113d5c75a5bd33b1b5fe399d83d94a671eb40658 Mon Sep 17 00:00:00 2001 From: David Zafman Date: Mon, 28 Sep 2015 10:59:42 -0700 Subject: [PATCH] osd: Don't crash if OI_ATTR attribute is missing or corrupt Signed-off-by: David Zafman (cherry picked from commit e0b39650028205e9d9e314b75c444cc8cf055a31) --- src/osd/PG.cc | 12 +++++++++++- src/osd/osd_types.h | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 634dc5656055f..43f320552f8e0 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -3600,8 +3600,18 @@ void PG::_scan_snaps(ScrubMap &smap) if (hoid.snap < CEPH_MAXSNAP) { // fake nlinks for old primaries bufferlist bl; + if (o.attrs.find(OI_ATTR) == o.attrs.end()) { + o.nlinks = 0; + continue; + } bl.push_back(o.attrs[OI_ATTR]); - object_info_t oi(bl); + object_info_t oi; + try { + oi = bl; + } catch(...) { + o.nlinks = 0; + continue; + } if (oi.snaps.empty()) { // Just head o.nlinks = 1; diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index b058c135ce2ac..7557494a0af4a 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -2987,6 +2987,10 @@ struct object_info_t { object_info_t(bufferlist& bl) { decode(bl); } + object_info_t operator=(bufferlist& bl) { + decode(bl); + return *this; + } }; WRITE_CLASS_ENCODER(object_info_t) -- 2.39.5