osd: check the length of the map before accessing the first element

Signed-off-by: Guang Yang yguang@yahoo-inc.com
This commit is contained in:
Guang G Yang 2015-07-28 16:25:53 +00:00 committed by David Zafman
parent 78e784d202
commit cabfe13781

View File

@ -9,11 +9,11 @@ int ECUtil::decode(
ErasureCodeInterfaceRef &ec_impl,
map<int, bufferlist> &to_decode,
bufferlist *out) {
assert(to_decode.size());
uint64_t total_data_size = to_decode.begin()->second.length();
assert(to_decode.size());
assert(total_data_size % sinfo.get_chunk_size() == 0);
assert(out);
assert(out->length() == 0);
@ -47,10 +47,9 @@ int ECUtil::decode(
ErasureCodeInterfaceRef &ec_impl,
map<int, bufferlist> &to_decode,
map<int, bufferlist*> &out) {
assert(to_decode.size());
uint64_t total_data_size = to_decode.begin()->second.length();
assert(to_decode.size());
assert(total_data_size % sinfo.get_chunk_size() == 0);
for (map<int, bufferlist>::iterator i = to_decode.begin();