diff options
author | Yehuda Sadeh <yehuda@redhat.com> | 2016-07-30 01:07:01 +0200 |
---|---|---|
committer | Yehuda Sadeh <yehuda@redhat.com> | 2016-07-30 01:07:01 +0200 |
commit | 4410eedc83f2b041f40b63e847f943b07b435d28 (patch) | |
tree | 40ca5a083d3018cb1239407a8550501e73bcb2e7 /src/test/rgw/test_rgw_bencode.cc | |
parent | Merge pull request #10177 from BlaXpirit/ceph-tests-py3 (diff) | |
download | ceph-4410eedc83f2b041f40b63e847f943b07b435d28.tar.xz ceph-4410eedc83f2b041f40b63e847f943b07b435d28.zip |
test_rgw_bencode: null terminate strings before checking
Fixes: http://tracker.ceph.com/issues/16861
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
Diffstat (limited to 'src/test/rgw/test_rgw_bencode.cc')
-rw-r--r-- | src/test/rgw/test_rgw_bencode.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/test/rgw/test_rgw_bencode.cc b/src/test/rgw/test_rgw_bencode.cc index 177d72f327e..66fa92a8a17 100644 --- a/src/test/rgw/test_rgw_bencode.cc +++ b/src/test/rgw/test_rgw_bencode.cc @@ -13,7 +13,9 @@ TEST(Bencode, String) decode.bencode("bar", bl); decode.bencode("baz", bl); - ASSERT_STREQ("3:foo3:bar3:baz", bl.c_str()); + string s(bl.c_str(), bl.length()); + + ASSERT_STREQ("3:foo3:bar3:baz", s.c_str()); } TEST(Bencode, Integers) @@ -25,7 +27,9 @@ TEST(Bencode, Integers) decode.bencode(-3, bl); decode.bencode(7, bl); - ASSERT_STREQ("i0ei-3ei7e", bl.c_str()); + string s(bl.c_str(), bl.length()); + + ASSERT_STREQ("i0ei-3ei7e", s.c_str()); } TEST(Bencode, Dict) @@ -38,7 +42,9 @@ TEST(Bencode, Dict) decode.bencode("bar", "baz", bl); decode.bencode_end(bl); - ASSERT_STREQ("d3:fooi5e3:bar3:baze", bl.c_str()); + string s(bl.c_str(), bl.length()); + + ASSERT_STREQ("d3:fooi5e3:bar3:baze", s.c_str()); } TEST(Bencode, List) @@ -51,5 +57,7 @@ TEST(Bencode, List) decode.bencode("bar", "baz", bl); decode.bencode_end(bl); - ASSERT_STREQ("l3:fooi5e3:bar3:baze", bl.c_str()); + string s(bl.c_str(), bl.length()); + + ASSERT_STREQ("l3:fooi5e3:bar3:baze", s.c_str()); } |