From: Colin Patrick McCabe Date: Sun, 24 Oct 2010 21:22:00 +0000 (-0700) Subject: cap_reconnect_t: ignore embedded NULLs in the path X-Git-Tag: v0.23~114 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a869b35abdab37bd4505f435bf0f7ab1860b28cc;p=ceph.git cap_reconnect_t: ignore embedded NULLs in the path Signed-off-by: Colin McCabe --- diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index f33c85a89ea7..151b83d81d5f 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -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)