summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorBrad Hubbard <bhubbard@redhat.com>2015-09-14 08:00:43 +0200
committerBrad Hubbard <bhubbard@redhat.com>2015-09-15 10:58:44 +0200
commit26bcb362f46daaef6f564e6d10c0f2439098ed91 (patch)
tree3a9fa55649fc93f8774ee3ee48a20e2ea2996dfe /examples
parentMerge pull request #5901 from yuyuyu101/wip-13001 (diff)
downloadceph-26bcb362f46daaef6f564e6d10c0f2439098ed91.tar.xz
ceph-26bcb362f46daaef6f564e6d10c0f2439098ed91.zip
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 <bhubbard@redhat.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/librados/hello_world.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/examples/librados/hello_world.cc b/examples/librados/hello_world.cc
index cb5476ffc84..9d3713495a3 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;
}
}