]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: add check when try to get_block_device_size()
authorxie xingguo <xie.xingguo@zte.com.cn>
Fri, 22 Jul 2016 03:11:33 +0000 (11:11 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Fri, 29 Jul 2016 03:13:48 +0000 (11:13 +0800)
If "id" passed in is greater than bdev.size(), then
bdev[id] is undefined and the code is at risk of accessing
violation.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/BlueFS.cc

index a031e51835cbd16a84bbb34bfaf7c0e0acb6dce6..f8e3dc1d4429809e9353a75302ed62fae6734bd4 100644 (file)
@@ -127,7 +127,7 @@ int BlueFS::add_block_device(unsigned id, string path)
 
 uint64_t BlueFS::get_block_device_size(unsigned id)
 {
-  if (bdev[id])
+  if (id < bdev.size() && bdev[id])
     return bdev[id]->get_size();
   return 0;
 }