]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/ceph-dencoder: Add an option stray_okay
authorKotreshHR <khiremat@redhat.com>
Tue, 9 May 2023 03:12:40 +0000 (08:42 +0530)
committerKotresh HR <khiremat@redhat.com>
Tue, 4 Mar 2025 11:15:52 +0000 (16:45 +0530)
The ceph-dencoder tool fails to decode if the
stray data is present at the end. Add an option
'stray_okay' to force the decode even if stray
data is present at the end.

Fixes: https://tracker.ceph.com/issues/69339
Signed-off-by: Kotresh HR <khiremat@redhat.com>
src/tools/ceph-dencoder/ceph_dencoder.cc
src/tools/ceph-dencoder/denc_registry.h

index 24640f9b51d656e5aa09bb0b3a7ef27d76993742..a7273622a29e501e9acc3be9ccfb62a708f5c173 100644 (file)
@@ -274,6 +274,12 @@ int main(int argc, const char **argv)
        return 0;
       else
        return 1;
+    } else if (*i == string("stray_okay")) {
+      if (!den) {
+       cerr << "must first select type with 'type <name>'" << std::endl;
+       return 1;
+      }
+      den->set_stray_okay();
     } else {
       cerr << "unknown option '" << *i << "'" << std::endl;
       return 1;
index 61acc833b90ee3a55ecf32f5a7c26256e1e8a9a0..4a24162ff1efbdbff504d1687b6fca06e2c23a1d 100644 (file)
@@ -29,6 +29,7 @@ struct Dencoder {
   virtual int num_generated() = 0;
   virtual std::string select_generated(unsigned n) = 0;
   virtual bool is_deterministic() = 0;
+  virtual void set_stray_okay() = 0;
   unsigned get_struct_v(bufferlist bl, uint64_t seek) const {
     auto p = bl.cbegin(seek);
     uint8_t struct_v = 0;
@@ -98,6 +99,10 @@ public:
   bool is_deterministic() override {
     return !nondeterministic;
   }
+
+  void set_stray_okay() {
+    stray_okay = true;
+  }
 };
 
 template<class T>
@@ -220,6 +225,8 @@ public:
   bool is_deterministic() override {
     return true;
   }
+  void set_stray_okay() override {
+  }
 
   //void print(ostream& out) {
   //out << m_object << std::endl;