]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file: avoid evaluating nullptr for readdir offset 20345/head
authorMatt Benjamin <mbenjamin@redhat.com>
Sat, 27 Jan 2018 21:27:45 +0000 (16:27 -0500)
committerPrashant D <pdhange@redhat.com>
Wed, 7 Feb 2018 03:37:15 +0000 (22:37 -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>
(cherry picked from commit bae94c6869018f54b01cb109f96e4062394be69d)

src/rgw/rgw_file.cc
src/rgw/rgw_file.h

index 6a5f39542f21e3045c9ac5eae521f35cbe3a83ce..38642110f94908a45ff3862a0bcf1d3238db32db 100644 (file)
@@ -1927,7 +1927,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 9c82694de76c04ff7f52fddcd2df7884b3358e19..7b7b8aa4d35278d297e9b5a89ce9afab400b29de 100644 (file)
@@ -1334,9 +1334,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;
   }
 
@@ -1522,10 +1528,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;
   }