]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Examples: hello_world.cc, content displayed after read is not null terminated. 5912/head
authorBrad Hubbard <bhubbard@redhat.com>
Mon, 14 Sep 2015 06:00:43 +0000 (16:00 +1000)
committerBrad Hubbard <bhubbard@redhat.com>
Tue, 15 Sep 2015 08:58:44 +0000 (18:58 +1000)
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>
examples/librados/hello_world.cc

index cb5476ffc84277149dd4c7afe124ae6a77b804eb..9d3713495a3bd2e98031bd107d953d7b1d7105ef 100644 (file)
@@ -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;
     }
   }