From: Yan, Zheng Date: Thu, 11 Apr 2019 08:42:35 +0000 (+0800) Subject: mds: fix SnapRealm::resolve_snapname for long name X-Git-Tag: v14.2.2~89^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=06ec9d2d91aaf37b8888542c8e65040981e9d011;p=ceph.git mds: fix SnapRealm::resolve_snapname for long name Fixes: https://tracker.ceph.com/issues/38832 Signed-off-by: "Yan, Zheng" (cherry picked from commit 7c6ec030cd9dece9e89347cdbf83514376eb29da) --- diff --git a/src/mds/SnapRealm.cc b/src/mds/SnapRealm.cc index 242d8fc7bb0..ee906a3a48d 100644 --- a/src/mds/SnapRealm.cc +++ b/src/mds/SnapRealm.cc @@ -454,15 +454,12 @@ snapid_t SnapRealm::resolve_snapname(std::string_view n, inodeno_t atino, snapid // first try me dout(10) << "resolve_snapname '" << n << "' in [" << first << "," << last << "]" << dendl; - //snapid_t num; - //if (n[0] == '~') num = atoll(n.c_str()+1); - bool actual = (atino == inode->ino()); string pname; inodeno_t pino; if (n.length() && n[0] == '_') { - int next_ = n.find('_', 1); - if (next_ > 1) { + size_t next_ = n.find_last_of('_'); + if (next_ > 1 && next_ + 1 < n.length()) { pname = n.substr(1, next_ - 1); pino = atoll(n.data() + next_ + 1); dout(10) << " " << n << " parses to name '" << pname << "' dirino " << pino << dendl;