From: David Zafman Date: Mon, 28 Sep 2015 17:59:42 +0000 (-0700) Subject: osd: Don't crash if OI_ATTR attribute is missing or corrupt X-Git-Tag: v0.94.7~28^2~1^2~17 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=113d5c75a5bd33b1b5fe399d83d94a671eb40658;p=ceph.git osd: Don't crash if OI_ATTR attribute is missing or corrupt Signed-off-by: David Zafman (cherry picked from commit e0b39650028205e9d9e314b75c444cc8cf055a31) --- diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 634dc565605..43f320552f8 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 b058c135ce2..7557494a0af 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)