From: Colin Patrick McCabe Date: Thu, 4 Nov 2010 22:46:55 +0000 (-0700) Subject: PGMonitor::update_from_paxos: check for bad input X-Git-Tag: v0.23~22^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=62716aa7c9a264c7a575bbccde0d8a7002563210;p=ceph.git PGMonitor::update_from_paxos: check for bad input Be more robust against bad data coming in from the network. Signed-off-by: Colin McCabe --- diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index c793b7267b04..7e75dfab2824 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -78,8 +78,17 @@ bool PGMonitor::update_from_paxos() version_t v = paxos->get_latest(latest); if (v) { dout(7) << "update_from_paxos startup: got latest latest full pgmap v" << v << dendl; - bufferlist::iterator p = latest.begin(); - pg_map.decode(p); + try { + PGMap tmp_pg_map; + bufferlist::iterator p = latest.begin(); + tmp_pg_map.decode(p); + pg_map = tmp_pg_map; + } + catch (const std::exception &e) { + dout(0) << "PGMonitor::update_from_paxos: error parsing update: " + << e.what() << dendl; + return false; + } } } @@ -91,8 +100,15 @@ bool PGMonitor::update_from_paxos() dout(7) << "update_from_paxos applying incremental " << pg_map.version+1 << dendl; PGMap::Incremental inc; - bufferlist::iterator p = bl.begin(); - inc.decode(p); + try { + bufferlist::iterator p = bl.begin(); + inc.decode(p); + } + catch (const std::exception &e) { + dout(0) << "PGMonitor::update_from_paxos: error parsing " + << "incremental update: " << e.what() << dendl; + return false; + } pg_map.apply_incremental(inc); dout(10) << pg_map << dendl;