mirror of
https://github.com/ceph/ceph
synced 2025-01-01 08:32:24 +00:00
Merge pull request #10581 from dillaman/wip-16887
librbd: prevent creation of v2 image ids that are too large Reviewed-by: Mykola Golub <mgolub@mirantis.com>
This commit is contained in:
commit
8f8b92f3a1
@ -1143,6 +1143,14 @@ int mirror_image_disable_internal(ImageCtx *ictx, bool force,
|
||||
extra = rand() % 0xFFFFFFFF;
|
||||
bid_ss << std::hex << bid << std::hex << extra;
|
||||
id = bid_ss.str();
|
||||
|
||||
// ensure the image id won't overflow the fixed block name size
|
||||
const size_t max_id_length = RBD_MAX_BLOCK_NAME_SIZE -
|
||||
strlen(RBD_DATA_PREFIX) - 1;
|
||||
if (id.length() > max_id_length) {
|
||||
id = id.substr(id.length() - max_id_length);
|
||||
}
|
||||
|
||||
r = cls_client::set_id(&io_ctx, id_obj, id);
|
||||
if (r < 0) {
|
||||
lderr(cct) << "error setting image id: " << cpp_strerror(r) << dendl;
|
||||
|
Loading…
Reference in New Issue
Block a user