]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file: avoid evaluating nullptr for readdir offset 20145/head
authorMatt Benjamin <mbenjamin@redhat.com>
Sat, 27 Jan 2018 21:27:45 +0000 (16:27 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Sat, 27 Jan 2018 21:40:06 +0000 (16:40 -0500)
I've found by experimentation that passing a null pointer
as a value to a CachedPrebufferedStreambuf ostream caused
subsequent log prints to be squelched.

(That's likely a bug, doesn't happen when the thread_local
optimization change is reverted.)

Fixes: https://tracker.ceph.com/issues/22820
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_file.cc
src/rgw/rgw_file.h

index e6f16ec3706fd2390842416a743877b500770619..68dd18ec3816b6f112e0b2624eb4c110d2eda4cc 100644 (file)
@@ -1939,7 +1939,7 @@ int rgw_readdir2(struct rgw_fs *rgw_fs,
 
   lsubdout(parent->get_fs()->get_context(), rgw, 15)
     << __func__
-    << " offset=" << name
+    << " offset=" << ((name) ? name : "(nil)")
     << dendl;
 
   if ((! name) &&
index d4e5333e0100789578ff0ea2cc41c464599d1f65..ec19898ae25a7eba4c68b6edee551b9af8e8081c 100644 (file)
@@ -1337,9 +1337,15 @@ public:
   }
 
   bool eof() {
-    lsubdout(cct, rgw, 15) << "READDIR offset: " << offset
-                          << " is_truncated: " << is_truncated
-                          << dendl;
+    if (unlikely(cct->_conf->subsys.should_gather(ceph_subsys_rgw, 15))) {
+      bool is_offset =
+       unlikely(! get<const char*>(&offset)) ||
+       !! get<const char*>(offset);
+      lsubdout(cct, rgw, 15) << "READDIR offset: " <<
+       ((is_offset) ? offset : "(nil)")
+                            << " is_truncated: " << is_truncated
+                            << dendl;
+    }
     return !is_truncated;
   }
 
@@ -1526,10 +1532,16 @@ public:
   }
 
   bool eof() {
-    lsubdout(cct, rgw, 15) << "READDIR offset: " << offset
-                          << " next marker: " << next_marker
-                          << " is_truncated: " << is_truncated
-                          << dendl;
+    if (unlikely(cct->_conf->subsys.should_gather(ceph_subsys_rgw, 15))) {
+      bool is_offset =
+       unlikely(! get<const char*>(&offset)) ||
+       !! get<const char*>(offset);
+      lsubdout(cct, rgw, 15) << "READDIR offset: " <<
+       ((is_offset) ? offset : "(nil)")
+                            << " next marker: " << next_marker
+                            << " is_truncated: " << is_truncated
+                            << dendl;
+    }
     return !is_truncated;
   }