From: xie xingguo Date: Fri, 22 Jul 2016 03:11:33 +0000 (+0800) Subject: os/bluestore: add check when try to get_block_device_size() X-Git-Tag: ses5-milestone5~155^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f6cfb48b92f2922ae664b92bdfc683a08e77b8a2;p=ceph.git os/bluestore: add check when try to get_block_device_size() 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 --- diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index a031e51835cb..f8e3dc1d4429 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -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; }