mirror of
https://github.com/ceph/ceph
synced 2025-01-20 10:01:45 +00:00
rbd.cc: tolerate lack of NUL-termination on block_name_prefix
Fixes: #7577 Signed-off-by: Dan Mick <dan.mick@inktank.com> Reviewed-by: Sage Weil <sage@inktank.com>
This commit is contained in:
parent
fab374b039
commit
fd76fec589
@ -521,6 +521,9 @@ static int do_show_info(const char *imgname, librbd::Image& image,
|
||||
f->dump_string("block_name_prefix", info.block_name_prefix);
|
||||
f->dump_int("format", (old_format ? 1 : 2));
|
||||
} else {
|
||||
char prefix[RBD_MAX_BLOCK_NAME_SIZE + 1];
|
||||
strncpy(prefix, info.block_name_prefix, RBD_MAX_BLOCK_NAME_SIZE);
|
||||
prefix[RBD_MAX_BLOCK_NAME_SIZE] = '\0';
|
||||
cout << "rbd image '" << imgname << "':\n"
|
||||
<< "\tsize " << prettybyte_t(info.size) << " in "
|
||||
<< info.num_objs << " objects"
|
||||
@ -528,7 +531,7 @@ static int do_show_info(const char *imgname, librbd::Image& image,
|
||||
<< "\torder " << info.order
|
||||
<< " (" << prettybyte_t(info.obj_size) << " objects)"
|
||||
<< std::endl
|
||||
<< "\tblock_name_prefix: " << info.block_name_prefix
|
||||
<< "\tblock_name_prefix: " << prefix
|
||||
<< std::endl
|
||||
<< "\tformat: " << (old_format ? "1" : "2")
|
||||
<< std::endl;
|
||||
|
Loading…
Reference in New Issue
Block a user