From 91c1a228a65c790e43fde6cccba9a122ce6a5929 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 14 Oct 2016 15:35:06 -0400 Subject: [PATCH 1/3] ceph_test_objectstore: test unprintable chars Signed-off-by: Sage Weil --- src/test/objectstore/store_test.cc | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index f519135e46e..f219566ef7b 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -229,6 +229,37 @@ TEST_P(StoreTest, IORemount) { } } +TEST_P(StoreTest, UnprintableCharsName) { + ObjectStore::Sequencer osr("test"); + coll_t cid; + string name = "funnychars_"; + for (unsigned i = 0; i < 256; ++i) { + name.push_back(i); + } + ghobject_t oid(hobject_t(sobject_t(name, CEPH_NOSNAP))); + int r; + { + cerr << "create collection + object" << std::endl; + ObjectStore::Transaction t; + t.create_collection(cid, 0); + t.touch(cid, oid); + r = apply_transaction(store, &osr, std::move(t)); + ASSERT_EQ(r, 0); + } + r = store->umount(); + ASSERT_EQ(0, r); + r = store->mount(); + ASSERT_EQ(0, r); + { + cout << "removing" << std::endl; + ObjectStore::Transaction t; + t.remove(cid, oid); + t.remove_collection(cid); + r = apply_transaction(store, &osr, std::move(t)); + ASSERT_EQ(r, 0); + } +} + TEST_P(StoreTest, FiemapEmpty) { ObjectStore::Sequencer osr("test"); coll_t cid; From a86d78ee6509bd09c695213fe996c50620eb6b8a Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 14 Oct 2016 15:35:33 -0400 Subject: [PATCH 2/3] os/bluestore: fix escaping of odd chars >0x80 in keys Signed-off-by: Sage Weil --- src/os/bluestore/BlueStore.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index aefa266ed21..336b1f8cdf5 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -114,10 +114,10 @@ static void append_escaped(const string &in, string *out) char hexbyte[8]; for (string::const_iterator i = in.begin(); i != in.end(); ++i) { if (*i <= '#') { - snprintf(hexbyte, sizeof(hexbyte), "#%02x", (unsigned)*i); + snprintf(hexbyte, sizeof(hexbyte), "#%02x", (uint8_t)*i); out->append(hexbyte); } else if (*i >= '~') { - snprintf(hexbyte, sizeof(hexbyte), "~%02x", (unsigned)*i); + snprintf(hexbyte, sizeof(hexbyte), "~%02x", (uint8_t)*i); out->append(hexbyte); } else { out->push_back(*i); From 659da5f16d662c771632d927906516f3fbfdda1e Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 14 Oct 2016 15:35:58 -0400 Subject: [PATCH 3/3] os/kstore: fix escaping of chars > 0x80 in keys Signed-off-by: Sage Weil --- src/os/kstore/KStore.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/os/kstore/KStore.cc b/src/os/kstore/KStore.cc index 31af5c27551..e4498192fd4 100755 --- a/src/os/kstore/KStore.cc +++ b/src/os/kstore/KStore.cc @@ -84,10 +84,10 @@ static void append_escaped(const string &in, string *out) char hexbyte[8]; for (string::const_iterator i = in.begin(); i != in.end(); ++i) { if (*i <= '#') { - snprintf(hexbyte, sizeof(hexbyte), "#%02x", (unsigned)*i); + snprintf(hexbyte, sizeof(hexbyte), "#%02x", (uint8_t)*i); out->append(hexbyte); } else if (*i >= '~') { - snprintf(hexbyte, sizeof(hexbyte), "~%02x", (unsigned)*i); + snprintf(hexbyte, sizeof(hexbyte), "~%02x", (uint8_t)*i); out->append(hexbyte); } else { out->push_back(*i);