From: Brad Hubbard Date: Mon, 14 Sep 2015 06:00:43 +0000 (+1000) Subject: Examples: hello_world.cc, content displayed after read is not null terminated. X-Git-Tag: v9.1.0~140^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=26bcb362f46daaef6f564e6d10c0f2439098ed91;p=ceph.git Examples: hello_world.cc, content displayed after read is not null terminated. Copy contents of bufferlist to a string before sending to stdout since a bufferlist is not null terminated. Fixes: #7822 Signed-off-by: Brad Hubbard --- diff --git a/examples/librados/hello_world.cc b/examples/librados/hello_world.cc index cb5476ffc842..9d3713495a3b 100644 --- a/examples/librados/hello_world.cc +++ b/examples/librados/hello_world.cc @@ -173,7 +173,9 @@ int main(int argc, const char **argv) } else { std::cout << "we read our object " << object_name << ", and got back " << ret << " bytes with contents\n" - << read_buf.c_str() << std::endl; + std::string read_string; + read_buf.copy(0, ret, read_string); + std::cout << read_string << std::endl; } }