]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg: check compat_version before decoding
authorSage Weil <sage.weil@dreamhost.com>
Thu, 2 Feb 2012 23:02:41 +0000 (15:02 -0800)
committerSage Weil <sage.weil@dreamhost.com>
Fri, 10 Feb 2012 06:09:05 +0000 (22:09 -0800)
If the newly constructed message's version is older than the
compat_version, don't even try to decode; just fail.

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/msg/Message.cc

index f863b8ae4ccfc6a61074040868b67f670ff86685..ff71356bc2a22f6797d518ed3973ee38965227b1 100644 (file)
@@ -605,6 +605,21 @@ Message *decode_message(CephContext *cct, ceph_msg_header& header, ceph_msg_foot
     }
     return 0;
   }
+
+  // m->header.version, if non-zero, should be populated with the
+  // newest version of the encoding the code supports.  If set, check
+  // it against compat_version.
+  if (m->get_header().version &&
+      m->get_header().version < header.compat_version) {
+    ldout(cct, 0) << "will not decode message of type " << type
+                 << " version " << header.version
+                 << " because compat_version " << header.compat_version
+                 << " > supported version " << m->get_header().version << dendl;
+    if (cct->_conf->ms_die_on_bad_msg)
+      assert(0);
+    m->put();
+    return 0;
+  }
   
   m->set_header(header);
   m->set_footer(footer);