]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file: readdir: do not construct markers w/leading '/' 29969/head
authorMatt Benjamin <mbenjamin@redhat.com>
Wed, 14 Aug 2019 18:11:16 +0000 (14:11 -0400)
committerNathan Cutler <ncutler@suse.com>
Wed, 28 Aug 2019 15:37:57 +0000 (17:37 +0200)
This case arises when listing the top directory of a bucket, and,
with proper continued enumeration, would generate a non-terminating
loop if a directory contained names which sort lexically before '/'.

Fixes: https://tracker.ceph.com/issues/41252
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
(cherry picked from commit ca546fc53e5111052cbd7da35cb3105dde9b8bd1)

src/rgw/rgw_file.h

index 46623ecb4b0f62aadf165743af11e8398d4bb7cf..91308140c1ee41615465a0f14ba604301f925ea4 100644 (file)
@@ -499,17 +499,17 @@ namespace rgw {
        reserve += (1 + tfh->object_name().length());
        tfh = tfh->parent;
       }
-      bool first = true;
+      int pos = 1;
       path.reserve(reserve);
       for (auto& s : boost::adaptors::reverse(segments)) {
-       if (! first)
+       if (pos > 1) {
          path += "/";
-       else {
+       else {
          if (!omit_bucket && (path.front() != '/')) // pretty-print
            path += "/";
-         first = false;
        }
        path += *s;
+       ++pos;
       }
       return path;
     }
@@ -1453,8 +1453,9 @@ public:
       const char* mk = get<const char*>(offset);
       if (mk) {
        std::string tmark{rgw_fh->relative_object_name()};
-       tmark += "/";
-       tmark += mk;    
+       if (tmark.length() > 0)
+         tmark += "/";
+       tmark += mk;
        marker = rgw_obj_key{std::move(tmark), "", ""};
       }
     }