Skip to content

Commit

Permalink
Examples: hello_world.cc, content displayed after read is not null te…
Browse files Browse the repository at this point in the history
…rminated.

Copy contents of bufferlist to a string before sending to stdout since a
bufferlist is not null terminated.

Fixes: ceph#7822
Signed-off-by: Brad Hubbard <[email protected]>
  • Loading branch information
badone committed Sep 15, 2015
1 parent 27d1e4d commit 26bcb36
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion examples/librados/hello_world.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 26bcb36

Please sign in to comment.