]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
BlueStore: fix wrong verification of object key
authorxie xingguo <xie.xingguo@zte.com.cn>
Wed, 13 Jan 2016 08:59:47 +0000 (16:59 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Thu, 14 Jan 2016 06:30:03 +0000 (14:30 +0800)
Fixes: #14353
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/BlueStore.cc

index 29ed6a45ec7ecd2b98ddc36225e2cf4bfb3250de..8c0b71637baf553ec13a3a19f09800122e1b01e2 100644 (file)
@@ -346,18 +346,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 - 0x8000000000000000;
+  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 != '.')
@@ -395,11 +395,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;
 }