From f6cfb48b92f2922ae664b92bdfc683a08e77b8a2 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Fri, 22 Jul 2016 11:11:33 +0800 Subject: [PATCH] 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 --- src/os/bluestore/BlueFS.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } -- 2.47.3