]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
PGMonitor::update_from_paxos: check for bad input
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 4 Nov 2010 22:46:55 +0000 (15:46 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 4 Nov 2010 23:22:21 +0000 (16:22 -0700)
Be more robust against bad data coming in from the network.

Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
src/mon/PGMonitor.cc

index c793b7267b04f487c3e78027e8c4411e5e6591f3..7e75dfab2824c6740660ebac1d8d092f5f8c6be4 100644 (file)
@@ -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;