From 7c6ec030cd9dece9e89347cdbf83514376eb29da Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Thu, 11 Apr 2019 16:42:35 +0800 Subject: [PATCH] mds: fix SnapRealm::resolve_snapname for long name Fixes: https://tracker.ceph.com/issues/38832 Signed-off-by: "Yan, Zheng" --- src/mds/SnapRealm.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/mds/SnapRealm.cc b/src/mds/SnapRealm.cc index 242d8fc7bb09..ee906a3a48d3 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; -- 2.47.3