]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cap_reconnect_t: ignore embedded NULLs in the path
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Sun, 24 Oct 2010 21:22:00 +0000 (14:22 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Sun, 24 Oct 2010 21:28:14 +0000 (14:28 -0700)
Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
src/mds/mdstypes.h

index f33c85a89ea7bf7358c9d2ad775611a64ab03265..151b83d81d5fe365b46cb4a2dd158b349f3acabe 100644 (file)
@@ -1334,10 +1334,23 @@ struct cap_reconnect_t {
     ::encode_nohead(flockbl, bl);
   }
   void decode(bufferlist::iterator& bl) {
-    ::decode(path, bl);
+    decode_path(path, bl);
     ::decode(capinfo, bl);
     ::decode_nohead(capinfo.flock_len, flockbl, bl);
   }
+private:
+  void decode_path(std::string &path, bufferlist::iterator& p) {
+    // Bypass the check for embedded NULLs by decoding into a raw byte buffer.
+    // We sometimes get paths with embedded NULLs from old kernel clients.
+    __u32 len;
+    ::decode(len, p);
+    if (len > PATH_MAX)
+      throw buffer::malformed_input("cap_reconnect_t::decode_path: PATH too long!");
+    char str[len + 1];
+    memset(str, 0, sizeof(str));
+    p.copy(len, str);
+    path = str;
+  }
 };
 WRITE_CLASS_ENCODER(cap_reconnect_t)