]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: validate SnapInfo::long_name before using it
authorYan, Zheng <zyan@redhat.com>
Wed, 11 Apr 2018 03:00:59 +0000 (11:00 +0800)
committerYan, Zheng <zyan@redhat.com>
Thu, 19 Apr 2018 03:32:18 +0000 (11:32 +0800)
SnapInfo::long_name becomes invalid after rename snapshot

Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/mds/snap.cc

index 1090180be7ea967d388fcaf1ba156fe1a6056efc..dc913f3ed16f1240b27d72b3c51ddc22e3215e9f 100644 (file)
@@ -70,7 +70,9 @@ ostream& operator<<(ostream& out, const SnapInfo &sn)
 
 std::string_view SnapInfo::get_long_name() const
 {
-  if (long_name.length() == 0) {
+  if (long_name.empty() ||
+      long_name.compare(1, name.size(), name) ||
+      long_name.find_last_of("_") != name.size() + 1) {
     char nm[80];
     snprintf(nm, sizeof(nm), "_%s_%llu", name.c_str(), (unsigned long long)ino);
     long_name = nm;