]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file: readdir: do not construct markers w/leading '/' 29670/head
authorMatt Benjamin <mbenjamin@redhat.com>
Wed, 14 Aug 2019 18:11:16 +0000 (14:11 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Wed, 14 Aug 2019 18:47:20 +0000 (14:47 -0400)
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>
src/rgw/rgw_file.h

index f3cb3bf960aff7927482bc405b1afd30e4fd8a08..5f42f7b105e8e9253e7abf4c5d4bb06594fd4da5 100644 (file)
@@ -502,17 +502,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;
     }
@@ -1467,8 +1467,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), "", ""};
       }
     }