Skip to content

Commit

Permalink
Merge pull request #11502 from liewegas/wip-bluestore-keybug
Browse files Browse the repository at this point in the history
os/bluestore: fix escaping of chars > 0x80

Reviewed-by: Igor Fedotov <ifedotov@mirantis.com>
  • Loading branch information
liewegas committed Oct 17, 2016
2 parents 311c7b7 + 659da5f commit 78e262a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/os/bluestore/BlueStore.cc
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/os/kstore/KStore.cc
Expand Up @@ -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);
Expand Down
31 changes: 31 additions & 0 deletions src/test/objectstore/store_test.cc
Expand Up @@ -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;
Expand Down

0 comments on commit 78e262a

Please sign in to comment.