From: Matt Benjamin Date: Sat, 27 Jan 2018 21:27:45 +0000 (-0500) Subject: rgw_file: avoid evaluating nullptr for readdir offset X-Git-Tag: v13.0.2~348^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bae94c6869018f54b01cb109f96e4062394be69d;p=ceph.git rgw_file: avoid evaluating nullptr for readdir offset 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 --- diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index e6f16ec3706f..68dd18ec3816 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -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) && diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index d4e5333e0100..ec19898ae25a 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -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(&offset)) || + !! get(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(&offset)) || + !! get(offset); + lsubdout(cct, rgw, 15) << "READDIR offset: " << + ((is_offset) ? offset : "(nil)") + << " next marker: " << next_marker + << " is_truncated: " << is_truncated + << dendl; + } return !is_truncated; }