From: xie xingguo Date: Wed, 13 Jan 2016 08:52:52 +0000 (+0800) Subject: kstore: fix wrong verification logic of object key X-Git-Tag: v10.0.3~45^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ab3fc3a608190d21af693dd991e58425f75cdeec;p=ceph.git kstore: fix wrong verification logic of object key Fixes: #14352 Signed-off-by: xie xingguo --- diff --git a/src/os/kstore/KStore.cc b/src/os/kstore/KStore.cc index 18a89e5192d..48063f63e57 100644 --- a/src/os/kstore/KStore.cc +++ b/src/os/kstore/KStore.cc @@ -302,18 +302,18 @@ static int get_key_object(const string& key, ghobject_t *oid) const char *p = key.c_str(); p = _key_decode_shard(p, &oid->shard_id); - if (!p) + if (!*p) return -2; uint64_t pool; p = _key_decode_u64(p, &pool); - if (!p) + if (!*p) return -3; oid->hobj.pool = pool - 0x8000000000000000ull; unsigned hash; p = _key_decode_u32(p, &hash); - if (!p) + if (!*p) return -4; oid->hobj.set_bitwise_key_u32(hash); if (*p != '.') @@ -351,11 +351,15 @@ static int get_key_object(const string& key, ghobject_t *oid) } p = _key_decode_u64(p, &oid->hobj.snap.val); - if (!p) + if (!*p) return -11; p = _key_decode_u64(p, &oid->generation); - if (!p) + if (*p) { + // if we get something other than a null terminator here, + // something goes wrong. return -12; + } + return 0; }